1Copyright (C) 2021-2023 Huawei Device Co., Ltd. 2Licensed under the Apache License, Version 2.0 (the "License"); 3you may not use this file except in compliance with the License. 4You may obtain a copy of the License at\n 5 6 http://www.apache.org/licenses/LICENSE-2.0 7 8Unless required by applicable law or agreed to in writing, software 9distributed under the License is distributed on an "AS IS" BASIS, 10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11See the License for the specific language governing permissions and 12limitations under the License. 13 14diff -Naur old/BUILD.gn new/BUILD.gn 15--- old/BUILD.gn 2021-01-01 00:00:00.000000000 +0000 16+++ new/BUILD.gn 2021-01-01 00:00:00.000000000 +0000 17@@ -19,134 +19,167 @@ 18 } 19 20 config("libinput-third_public_config") { 21- include_dirs = [ "export_include" ] 22+ include_dirs = [ 23+ "export_include", 24+ "include", 25+ "//third_party/FreeBSD/sys/dev/evdev", 26+ "src", 27+ ] 28 29- cflags = [] 30+ cflags = [ 31+ "-DHAVE_LIBEVDEV_DISABLE_PROPERTY=0", 32+ "-DHAVE_LIBWACOM=0", 33+ "-DHAVE_LOCALE_H=1", 34+ "-UHAVE_VERSIONSORT", 35+ ] 36 } 37 38 ohos_shared_library("libinput-third") { 39 sources = [ 40- "src/evdev-debounce.c", 41- "src/evdev-fallback.c", 42- "src/evdev-middle-button.c", 43- "src/evdev-mt-touchpad-buttons.c", 44- "src/evdev-mt-touchpad-edge-scroll.c", 45- "src/evdev-mt-touchpad-gestures.c", 46- "src/evdev-mt-touchpad-tap.c", 47- "src/evdev-mt-touchpad-thumb.c", 48- "src/evdev-mt-touchpad.c", 49- "src/evdev-tablet-pad-leds.c", 50- "src/evdev-tablet-pad.c", 51- "src/evdev-tablet.c", 52- "src/evdev-totem.c", 53- "src/evdev.c", 54+ "src/util-list.c", 55+ "src/util-ratelimit.c", 56+ "src/util-strings.c", 57+ "src/util-prop-parsers.c", 58+ "src/filter.c", 59 "src/filter-flat.c", 60 "src/filter-low-dpi.c", 61 "src/filter-mouse.c", 62- "src/filter-tablet.c", 63+ "src/filter-touchpad.c", 64 "src/filter-touchpad-flat.c", 65 "src/filter-touchpad-x230.c", 66- "src/filter-touchpad.c", 67+ "src/filter-tablet.c", 68 "src/filter-trackpoint.c", 69- "src/filter.c", 70+ "src/quirks.c", 71 "src/libinput.c", 72+ "src/evdev.c", 73+ "src/evdev-debounce.c", 74+ "src/evdev-fallback.c", 75+ "src/evdev-totem.c", 76+ "src/evdev-middle-button.c", 77+ "src/evdev-mt-touchpad.c", 78+ "src/evdev-mt-touchpad-tap.c", 79+ "src/evdev-mt-touchpad-thumb.c", 80+ "src/evdev-mt-touchpad-buttons.c", 81+ "src/evdev-mt-touchpad-edge-scroll.c", 82+ "src/evdev-mt-touchpad-gestures.c", 83+ "src/evdev-tablet.c", 84+ "src/evdev-tablet-pad.c", 85+ "src/evdev-tablet-pad-leds.c", 86 "src/path-seat.c", 87- "src/quirks.c", 88- "src/timer.c", 89 "src/udev-seat.c", 90- "src/util-list.c", 91- "src/util-prop-parsers.c", 92- "src/util-ratelimit.c", 93- "src/util-strings.c", 94- 95- # "src/libinput-util.c", 96+ "src/timer.c", 97+ "src/libinput-util.c", 98+ "src/evdev-joystick.c", 99 ] 100 101- configs = [ ":libinput-third_config" ] 102+ configs = [ 103+ ":libinput-third_config", 104+ ] 105 106- public_configs = [ ":libinput-third_public_config" ] 107+ public_configs = [ 108+ ":libinput-third_public_config", 109+ ] 110 111- deps = [] 112+ deps = [ 113+ ] 114 115 public_deps = [ 116- "//third_party/eudev:libudev", 117 "//third_party/libevdev:libevdev", 118+ "//third_party/eudev:libudev", 119 "//third_party/mtdev:libmtdev", 120 ] 121 122- part_name = "libinput" 123+ part_name = "input" 124 } 125- 126 ## Build libinput-third.so }}} 127 128+ 129 ohos_executable("libinput-debug") { 130 install_enable = true 131 132 sources = [ 133- "tools/libinput-debug-events.c", 134- "tools/shared.c", 135 "tools/shared.h", 136+ "tools/shared.c", 137+ "tools/libinput-debug-events.c", 138 ] 139 140- configs = [ ":libinput-third_config" ] 141+ configs = [ 142+ ":libinput-third_config", 143+ ] 144 145- public_configs = [ ":libinput-third_public_config" ] 146+ public_configs = [ 147+ ":libinput-third_public_config", 148+ ] 149 150- deps = [ ":libinput-third" ] 151+ deps = [ 152+ ":libinput-third", 153+ ] 154 155 public_deps = [ 156- "//third_party/eudev:libudev", 157 "//third_party/libevdev:libevdev", 158+ "//third_party/eudev:libudev", 159 "//third_party/mtdev:libmtdev", 160 ] 161 162- part_name = "libinput" 163+ part_name = "input" 164 } 165 166 ohos_executable("libinput-list") { 167 install_enable = true 168 169 sources = [ 170- "tools/libinput-list-devices.c", 171- "tools/shared.c", 172 "tools/shared.h", 173+ "tools/shared.c", 174+ "tools/libinput-list-devices.c", 175 ] 176 177- configs = [ ":libinput-third_config" ] 178+ configs = [ 179+ ":libinput-third_config", 180+ ] 181 182- public_configs = [ ":libinput-third_public_config" ] 183+ public_configs = [ 184+ ":libinput-third_public_config", 185+ ] 186 187- deps = [ ":libinput-third" ] 188+ deps = [ 189+ ":libinput-third", 190+ ] 191 192 public_deps = [ 193- "//third_party/eudev:libudev", 194 "//third_party/libevdev:libevdev", 195+ "//third_party/eudev:libudev", 196 "//third_party/mtdev:libmtdev", 197 ] 198 199- part_name = "libinput" 200+ part_name = "input" 201 } 202 203 ohos_executable("libinput-tablet") { 204 install_enable = true 205 206 sources = [ 207- "tools/libinput-debug-tablet.c", 208- "tools/shared.c", 209 "tools/shared.h", 210+ "tools/shared.c", 211+ "tools/libinput-debug-tablet.c", 212 ] 213 214- configs = [ ":libinput-third_config" ] 215+ configs = [ 216+ ":libinput-third_config", 217+ ] 218 219- public_configs = [ ":libinput-third_public_config" ] 220+ public_configs = [ 221+ ":libinput-third_public_config", 222+ ] 223 224- deps = [ ":libinput-third" ] 225+ deps = [ 226+ ":libinput-third", 227+ ] 228 229 public_deps = [ 230- "//third_party/eudev:libudev", 231 "//third_party/libevdev:libevdev", 232+ "//third_party/eudev:libudev", 233 "//third_party/mtdev:libmtdev", 234 ] 235 236- part_name = "libinput" 237-} 238+ part_name = "input" 239+} 240\ No newline at end of file 241diff -Naur old/export_include/libinput.h new/export_include/libinput.h 242--- old/export_include/libinput.h 2021-01-01 00:00:00.000000000 +0000 243+++ new/export_include/libinput.h 2021-01-01 00:00:00.000000000 +0000 244@@ -196,6 +196,22 @@ 245 LIBINPUT_DEVICE_CAP_TABLET_PAD = 4, 246 LIBINPUT_DEVICE_CAP_GESTURE = 5, 247 LIBINPUT_DEVICE_CAP_SWITCH = 6, 248+ LIBINPUT_DEVICE_CAP_JOYSTICK = 7, 249+}; 250+ 251+enum evdev_device_udev_tags { 252+ EVDEV_UDEV_TAG_INPUT = 1 << 0, 253+ EVDEV_UDEV_TAG_KEYBOARD = 1 << 1, 254+ EVDEV_UDEV_TAG_MOUSE = 1 << 2, 255+ EVDEV_UDEV_TAG_TOUCHPAD = 1 << 3, 256+ EVDEV_UDEV_TAG_TOUCHSCREEN = 1 << 4, 257+ EVDEV_UDEV_TAG_TABLET = 1 << 5, 258+ EVDEV_UDEV_TAG_JOYSTICK = 1 << 6, 259+ EVDEV_UDEV_TAG_ACCELEROMETER = 1 << 7, 260+ EVDEV_UDEV_TAG_TABLET_PAD = 1 << 8, 261+ EVDEV_UDEV_TAG_POINTINGSTICK = 1 << 9, 262+ EVDEV_UDEV_TAG_TRACKBALL = 1 << 10, 263+ EVDEV_UDEV_TAG_SWITCH = 1 << 11, 264 }; 265 266 /** 267@@ -321,6 +337,49 @@ 268 }; 269 270 /** 271+ * @ingroup event_joystick 272+ * 273+ * The source for a @ref LIBINPUT_EVENT_POINTER_AXIS event. See 274+ * libinput_event_get_joystick_axis_event() for details. 275+ * 276+ * @since 1.16.4 277+ */ 278+enum libinput_joystick_axis_source { 279+ LIBINPUT_JOYSTICK_AXIS_SOURCE_UNKNOWN = 0, 280+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X = 1 << 0, 281+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y = 1 << 1, 282+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z = 1 << 2, 283+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX = 1 << 3, 284+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY = 1 << 4, 285+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ = 1 << 5, 286+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE = 1 << 6, 287+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RUDDER = 1 << 7, 288+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_WHEEL = 1 << 8, 289+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS = 1 << 9, 290+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE = 1 << 10, 291+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X = 1 << 11, 292+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y = 1 << 12, 293+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1X = 1 << 13, 294+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1Y = 1 << 14, 295+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2X = 1 << 15, 296+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2Y = 1 << 16, 297+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3X = 1 << 17, 298+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3Y = 1 << 18, 299+}; 300+ 301+#define MAX_SOLTED_COORDS_NUM 10 302+struct sloted_coords { 303+ int32_t is_active; 304+ float x; 305+ float y; 306+}; 307+ 308+struct sloted_coords_info { 309+ struct sloted_coords coords[MAX_SOLTED_COORDS_NUM]; 310+ unsigned int active_count; 311+}; 312+ 313+/** 314 * @ingroup device 315 * 316 * Available tool types for a device with the @ref 317@@ -393,6 +452,17 @@ 318 LIBINPUT_TABLET_TOOL_TIP_DOWN = 1, 319 }; 320 321+struct libinput_event_joystick_axis_abs_info { 322+ int32_t code; 323+ int32_t value; 324+ int32_t minimum; 325+ int32_t maximum; 326+ int32_t fuzz; 327+ int32_t flat; 328+ int32_t resolution; 329+ float standardValue; 330+}; 331+ 332 /** 333 * @defgroup tablet_pad_modes Tablet pad modes 334 * 335@@ -822,6 +892,13 @@ 336 */ 337 LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS, 338 339+ LIBINPUT_EVENT_POINTER_TAP, 340+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD, 341+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD, 342+ 343+ LIBINPUT_EVENT_JOYSTICK_BUTTON = 450, 344+ LIBINPUT_EVENT_JOYSTICK_AXIS, 345+ 346 LIBINPUT_EVENT_TOUCH_DOWN = 500, 347 LIBINPUT_EVENT_TOUCH_UP, 348 LIBINPUT_EVENT_TOUCH_MOTION, 349@@ -832,6 +909,10 @@ 350 */ 351 LIBINPUT_EVENT_TOUCH_FRAME, 352 353+ LIBINPUT_EVENT_TOUCHPAD_DOWN = 550, 354+ LIBINPUT_EVENT_TOUCHPAD_UP, 355+ LIBINPUT_EVENT_TOUCHPAD_MOTION, 356+ 357 /** 358 * One or more axes have changed state on a device with the @ref 359 * LIBINPUT_DEVICE_CAP_TABLET_TOOL capability. This event is only sent 360@@ -1084,6 +1165,19 @@ 361 /** 362 * @ingroup event 363 * 364+ * Return the touchpad event that is this input event. If the event type does 365+ * not match the touchpad event types, this function returns NULL. 366+ * 367+ * The inverse of this function is libinput_event_touchpad_get_base_event(). 368+ * 369+ * @return A touch event, or NULL for other events 370+ */ 371+struct libinput_event_touch * 372+libinput_event_get_touchpad_event(struct libinput_event *event); 373+ 374+/** 375+ * @ingroup event 376+ * 377 * Return the gesture event that is this input event. If the event type does 378 * not match the gesture event types, this function returns NULL. 379 * 380@@ -1486,6 +1580,21 @@ 381 /** 382 * @ingroup event_pointer 383 * 384+ * For the button of a @ref LIBINPUT_EVENT_POINTER_BUTTON event, return the 385+ * total number of fingers on touchpad. 386+ * 387+ * @note It is an application bug to call this function for events other than 388+ * @ref LIBINPUT_EVENT_POINTER_BUTTON. For other events, this function 389+ * returns 0. 390+ * 391+ * @return The finger counts for touchpad button event 392+ */ 393+uint32_t 394+libinput_event_pointer_get_finger_count( 395+ struct libinput_event_pointer *event); 396+/** 397+ * @ingroup event_pointer 398+ * 399 * Check if the event has a valid value for the given axis. 400 * 401 * If this function returns non-zero for an axis and 402@@ -1870,6 +1979,120 @@ 403 uint32_t height); 404 405 /** 406+ * @brief 获取触摸屏的工具类型区域属性 407+ */ 408+int32_t 409+libinput_event_touch_get_tool_type(struct libinput_event_touch *event); 410+ 411+/** 412+ * @ingroup event_touch 413+ * 414+ * Returns the absolute x coordinate of the center point of the current tool 415+ * area, in mm from the upper left corner of the device. To get the 416+ * corresponding output screen coordinates, use 417+ * libinput_event_touch_get_tool_x_transformed(). 418+ * 419+ * @param event The libinput touch event 420+ * @return The current absolute x coordinate 421+ */ 422+double 423+libinput_event_touch_get_tool_x(struct libinput_event_touch *event); 424+ 425+/** 426+ * @ingroup event_touch 427+ * 428+ * Returns the absolute x coordinate of the center point of the current tool 429+ * area, converted to screen coordinates. 430+ * 431+ * @param event The libinput touch event 432+ * @param width The current output screen width 433+ * @return The current absolute x coordinate transformed to a screen coordinate 434+ */ 435+double 436+libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event, 437+ uint32_t width); 438+ 439+/** 440+ * @ingroup event_touch 441+ * 442+ * Returns the absolute y coordinate of the center point of the current tool 443+ * area, in mm from the upper left corner of the device. To get the 444+ * corresponding output screen coordinates, use 445+ * libinput_event_touch_get_tool_y_transformed(). 446+ * 447+ * @param event The libinput touch event 448+ * @return The current absolute y coordinate 449+ */ 450+double 451+libinput_event_touch_get_tool_y(struct libinput_event_touch *event); 452+ 453+/** 454+ * @ingroup event_touch 455+ * 456+ * Returns the absolute y coordinate of the center point of the current tool 457+ * area, converted to screen coordinates. 458+ * 459+ * @param event The libinput touch event 460+ * @param height The current output screen height 461+ * @return The current absolute y coordinate transformed to a screen coordinate 462+ */ 463+double 464+libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event, 465+ uint32_t height); 466+ 467+/** 468+ * @ingroup event_touch 469+ * 470+ * Returns the width of the current tool area. To get the corresponding output 471+ * screen width, use 472+ * libinput_event_touch_get_tool_width_transformed(). 473+ * 474+ * @param event The libinput touch event 475+ * @return The current width 476+ */ 477+double 478+libinput_event_touch_get_tool_width(struct libinput_event_touch *event); 479+ 480+/** 481+ * @ingroup event_touch 482+ * 483+ * Returns the width of the current tool area, converted to screen width. 484+ * 485+ * @param event The libinput touch event 486+ * @param width The current output screen width 487+ * @return Convert current width to screen width 488+ */ 489+double 490+libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event, 491+ uint32_t width); 492+ 493+/** 494+ * @ingroup event_touch 495+ * 496+ * Returns the height of the current tool area. To get the corresponding output 497+ * screen height, use 498+ * libinput_event_touch_get_tool_height_transformed(). 499+ * 500+ * @param event The libinput touch event 501+ * @return The current height 502+ */ 503+double 504+libinput_event_touch_get_tool_height(struct libinput_event_touch *event); 505+ 506+/** 507+ * @ingroup event_touch 508+ * 509+ * Returns the height of the current tool area, converted to screen height. 510+ * 511+ * @param event The libinput touch event 512+ * @param height The current output screen height 513+ * @return Convert current height to screen height 514+ */ 515+double 516+libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event, 517+ uint32_t height); 518+ 519+/** 520 * @ingroup event_touch 521 * 522 * @return The generic libinput_event of this event 523@@ -1878,6 +2101,228 @@ 524 libinput_event_touch_get_base_event(struct libinput_event_touch *event); 525 526 /** 527+ * @defgroup event_touch Touchpad events 528+ * 529+ * Events from absolute touchpad devices. 530+ */ 531+ 532+/** 533+ * @ingroup event_touch 534+ * 535+ * @note Timestamps may not always increase. See the libinput documentation 536+ * for more details. 537+ * 538+ * @return The event time for this event 539+ */ 540+uint32_t 541+libinput_event_touchpad_get_time(struct libinput_event_touch *event); 542+ 543+/** 544+ * @ingroup event_touch 545+ * 546+ * @note Timestamps may not always increase. See the libinput documentation 547+ * for more details. 548+ * 549+ * @return The event time for this event in microseconds 550+ */ 551+uint64_t 552+libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event); 553+ 554+/** 555+ * @ingroup event_touch 556+ * 557+ * Get the slot of this touchpad event. See the kernel's multitouch 558+ * protocol B documentation for more information. 559+ * 560+ * If the touchpad event has no assigned slot, for example if it is from a 561+ * single touchpad device, this function returns -1. 562+ * 563+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 564+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION, 565+ * this function returns 0. 566+ * 567+ * @note It is an application bug to call this function for events of type 568+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or 569+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION. 570+ * 571+ * @return The slot of this touchpad event 572+ */ 573+int32_t 574+libinput_event_touchpad_get_slot(struct libinput_event_touch *event); 575+ 576+/** 577+ * @ingroup event_touch 578+ * 579+ * Get the seat slot of the touchpad event. A seat slot is a non-negative seat 580+ * wide unique identifier of an active touchpad point. 581+ * 582+ * Events from single touchpad devices will be represented as one individual 583+ * touchpad point per device. 584+ * 585+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 586+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION, 587+ * this function returns 0. 588+ * 589+ * @note It is an application bug to call this function for events of type 590+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or 591+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION. 592+ * 593+ * @return The seat slot of the touchpad event 594+ */ 595+int32_t 596+libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event); 597+ 598+/** 599+ * @ingroup event_touch 600+ * 601+ * Return the current absolute x coordinate of the touchpad event, in mm from 602+ * the top left corner of the device. 603+ * 604+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 605+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 606+ * 607+ * @note It is an application bug to call this function for events of type 608+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref 609+ * LIBINPUT_EVENT_TOUCHPAD_MOTION. 610+ * 611+ * @param event The libinput touchpad event 612+ * @return The current absolute x coordinate 613+ */ 614+double 615+libinput_event_touchpad_get_x(struct libinput_event_touch *event); 616+ 617+/** 618+ * @ingroup event_touch 619+ * 620+ * Return the current absolute y coordinate of the touchpad event, in mm from 621+ * the top left corner of the device. 622+ * 623+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 624+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 625+ * 626+ * @note It is an application bug to call this function for events of type 627+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref 628+ * LIBINPUT_EVENT_TOUCHPAD_MOTION. 629+ * 630+ * @param event The libinput touchpad event 631+ * @return The current absolute y coordinate 632+ */ 633+double 634+libinput_event_touchpad_get_y(struct libinput_event_touch *event); 635+ 636+/** 637+ * @ingroup event_touch 638+ * 639+ * Get the pressure of the touch pad 640+ * 641+ * @param event The libinput touch event 642+ * @return Touchpad pressure value 643+ * 644+ */ 645+double 646+libinput_event_touchpad_get_pressure(struct libinput_event_touch *event); 647+ 648+/** 649+ * @ingroup event_touch 650+ * 651+ * Gets the long axis of the touchpoint region of the touchpad 652+ * 653+ * @param event The libinput touch event 654+ * @return The long axis value of the touchpoint area of the touchpad 655+ */ 656+int32_t 657+libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event); 658+ 659+/** 660+ * @ingroup event_touch 661+ * 662+ * Gets the short axis of the touchpoint region of the touchpad 663+ * 664+ * @param event The libinput touch event 665+ * @return The short axis value of the touchpoint area of the touchpad 666+ */ 667+int32_t 668+libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event); 669+ 670+/** 671+ * @brief 获取触摸板的工具类型区域属性 672+ */ 673+int32_t 674+libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event); 675+ 676+/** 677+ * @brief 获取触摸板工具类型按钮是否按下 678+ */ 679+int32_t 680+libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType); 681+ 682+/** 683+ * @ingroup event_touch 684+ * 685+ * @return The generic libinput_event of this event 686+ */ 687+struct libinput_event * 688+libinput_event_touchpad_get_base_event(struct libinput_event_touch *event); 689+ 690+/** 691+ * @ingroup event_touch 692+ * 693+ * Return the X coordinate of the center of the contact tool contour, in mm from 694+ * the top left corner of the device. 695+ * 696+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 697+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 698+ * 699+ * @param event The libinput touchpad event 700+ * @return The X coordinate of the center of the contact tool contour 701+ */ 702+double 703+libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event); 704+ 705+/** 706+ * @ingroup event_touch 707+ * 708+ * Return the Y coordinate of the center of the contact tool contour, in mm from 709+ * the top left corner of the device. 710+ * 711+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 712+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 713+ * 714+ * @param event The libinput touchpad event 715+ * @return The Y coordinate of the center of the contact tool contour 716+ */ 717+double 718+libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event); 719+ 720+/** 721+ * @ingroup event_touch 722+ * 723+ * Return the width of the current tool area. 724+ * 725+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 726+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 727+ * 728+ * @param event The libinput touchpad event 729+ * @return The width of the current tool area 730+ */ 731+double 732+libinput_event_touchpad_get_tool_width(struct libinput_event_touch *event); 733+ 734+/** 735+ * @ingroup event_touch 736+ * 737+ * Return the height of the current tool area. 738+ * 739+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 740+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 741+ * 742+ * @param event The libinput touchpad event 743+ * @return The height of the current tool area 744+ */ 745+double 746+libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event); 747+ 748+/** 749 * @defgroup event_gesture Gesture events 750 * 751 * Gesture events are generated when a gesture is recognized on a touchpad. 752@@ -2090,6 +2535,49 @@ 753 libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event); 754 755 /** 756+ * 获取gesture中手指的坐标信息, idx表示手指的索引 757+ */ 758+int 759+libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx); 760+int 761+libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx); 762+/** 763+ * 获取带slot的touches信息, 仅支持LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE 764+ */ 765+struct sloted_coords_info * 766+libinput_event_gesture_get_solt_touches(struct libinput_event_gesture *event); 767+ 768+/** 769+ * @brief Obtain the device values the EV_LED event type 770+ * 771+ * @param device A current input device 772+ * @return int Obtained is Supported 773+ */ 774+int libinput_has_event_led_type(struct libinput_device *device); 775+ 776+/** 777+ * @brief Obtain the function key enablement status of a keyboard device 778+ * 779+ * @param device A current input device 780+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, 781+ * given code (see linux/input-event-codes.h). 782+ * @return int Obtained state 783+ */ 784+int libinput_get_funckey_state(struct libinput_device *device, unsigned int code); 785+ 786+/** 787+ * @brief Turn an LED on or off. Convenience function, if you need to modify multiple 788+ * LEDs simultaneously, use libinput_set_led_state() instead. 789+ * 790+ * @param device A current input device 791+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, 792+ * given code (see linux/input-event-codes.h). 793+ * @param state value Specifies whether to turn the LED on or off 794+ * @return int 0 on success, or a negative errno on failure 795+ */ 796+int libinput_set_led_state(struct libinput_device *device, unsigned int code, unsigned int state); 797+ 798+/** 799 * @defgroup event_tablet Tablet events 800 * 801 * Events that come from tools on tablet devices. For events from the pad, 802@@ -2817,6 +3305,19 @@ 803 /** 804 * @ingroup event_tablet 805 * 806+ * Get the stylus event type reported from evdev_tablet 807+ * 808+ * @param event The libinput tablet tool event 809+ * @return Tool type for stylus events 810+ * 811+ * @since 1.2 812+ */ 813+int32_t 814+libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event); 815+ 816+/** 817+ * @ingroup event_tablet 818+ * 819 * Return the high-level tool type for a tool object. 820 * 821 * The high level tool describes general interaction expected with the tool. 822@@ -3404,6 +3905,19 @@ 823 libinput_event_tablet_pad_get_time_usec(struct libinput_event_tablet_pad *event); 824 825 /** 826+ * @ingroup base 827+ * 828+ * @note Provide the sensor time when hardware perceive the event 829+ * 830+ * @param event The libinput event 831+ * @return The sensor time (microseconds) 832+ * 833+ * @since 1.7 834+ */ 835+uint64_t 836+libinput_event_get_sensortime(struct libinput_event *event); 837+ 838+/** 839 * @defgroup event_switch Switch events 840 * 841 * Events that come from switch devices. 842@@ -3663,6 +4177,56 @@ 843 int 844 libinput_dispatch(struct libinput *libinput); 845 846+/**************************************************************************** 847+* @brief : brief 848+* @author : fms 849+* @date : 2021/3/8 20:55 850+* @version : ver 1.0 851+* @inparam :libinput event 852+* @outparam : 853+*****************************************************************************/ 854+void 855+libinput_post_handle_event(struct libinput* libinput, 856+ struct libinput_event* event); 857+ 858+/**************************************************************************** 859+* @brief : get joystick button event 860+* @author : fms 861+* @date : 2021/3/12 10:56 862+* @version : ver 1.0 863+* @inparam : 864+* @outparam : 865+*****************************************************************************/ 866+struct libinput_event_joystick_button* 867+libinput_event_get_joystick_button_event(struct libinput_event* event); 868+ 869+/**************************************************************************** 870+* @brief : get joystick axis event 871+* @author : fms 872+* @date : 2021/3/12 10:56 873+* @version : ver 1.0 874+* @inparam : 875+* @outparam : 876+*****************************************************************************/ 877+struct libinput_event_joystick_axis* 878+ libinput_event_get_joystick_axis_event(struct libinput_event* event); 879+/** 880+ * @brief 获取轴事件的时间 881+ */ 882+uint64_t 883+libinput_event_get_joystick_axis_time(struct libinput_event_joystick_axis *event); 884+ 885+/** 886+ * @brief 获取joystick指定轴的数据是否变化 887+*/ 888+int32_t libinput_event_get_joystick_axis_value_is_changed(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis); 889+ 890+/** 891+ * @brief 获取joystick指定轴的abs信息 892+*/ 893+struct libinput_event_joystick_axis_abs_info * 894+libinput_event_get_joystick_axis_abs_info(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis); 895+ 896 /** 897 * @ingroup base 898 * 899@@ -4133,6 +4697,42 @@ 900 const char * 901 libinput_device_get_name(struct libinput_device *device); 902 903+/** @brief 获取设备类型*/ 904+enum evdev_device_udev_tags 905+libinput_device_get_tags(struct libinput_device* device); 906+ 907+/** @brief 设备按键能力查询*/ 908+int32_t 909+libinput_device_has_key(struct libinput_device* device, int32_t keyCode); 910+ 911+/** @brief 获取设备特定轴的最小值*/ 912+int32_t 913+libinput_device_get_axis_min(struct libinput_device* device, int32_t code); 914+ 915+/** @brief 获取设备特定轴的最大值*/ 916+int32_t 917+libinput_device_get_axis_max(struct libinput_device* device, int32_t code); 918+ 919+/** @brief 获取设备特定轴的fuzz值*/ 920+int32_t 921+libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code); 922+ 923+/** @brief 获取设备特定轴的flat值*/ 924+int32_t 925+libinput_device_get_axis_flat(struct libinput_device* device, int32_t code); 926+ 927+/** @brief 获取设备特定轴的resolution值*/ 928+int32_t 929+libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code); 930+ 931+/** @brief 获取设备的bustype值*/ 932+unsigned int 933+libinput_device_get_id_bustype(struct libinput_device* device); 934+ 935+/** @brief 获取设备的version值*/ 936+unsigned int 937+libinput_device_get_id_version(struct libinput_device* device); 938+ 939 /** 940 * @ingroup device 941 * 942@@ -4343,6 +4943,12 @@ 943 libinput_device_touch_get_touch_count(struct libinput_device *device); 944 945 /** 946+ * @brief 获取触摸屏工具类型按钮是否按下 947+ */ 948+int 949+libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType); 950+ 951+/** 952 * @ingroup device 953 * 954 * Check if a @ref LIBINPUT_DEVICE_CAP_SWITCH device has a switch of the 955@@ -6124,7 +6730,102 @@ 956 unsigned int 957 libinput_device_config_rotation_get_default_angle(struct libinput_device *device); 958 959+/** 960+ * @ingroup event 961+ * 962+ * Get the struct libinput_event_joystick_button from the event. 963+ * 964+ * @param event The libinput event 965+ * @return The libinput_event_joystick_button for this event. 966+ */ 967+struct libinput_event_joystick_button* 968+libinput_event_get_joystick_pointer_button_event(struct libinput_event* event); 969+ 970+/** 971+ * @ingroup event 972+ * 973+ * Get the time from the event. 974+ * 975+ * @param event The libinput_event_joystick_button 976+ * @return The time for this event. 977+ */ 978+uint64_t libinput_event_joystick_button_time(struct libinput_event_joystick_button* event); 979+ 980+/** 981+ * @ingroup event 982+ * 983+ * Get the key value from the event. 984+ * 985+ * @param event The libinput_event_joystick_button 986+ * @return The key value for this event. 987+ */ 988+uint32_t libinput_event_joystick_button_get_key(struct libinput_event_joystick_button* event); 989+ 990+/** 991+ * @ingroup event 992+ * 993+ * Get the seat key count from the event. 994+ * 995+ * @param event The libinput_event_joystick_button 996+ * @return The seat key count for this event. 997+ */ 998+uint32_t libinput_event_joystick_button_get_seat_key_count(struct libinput_event_joystick_button* event); 999+ 1000+/** 1001+ * @ingroup event 1002+ * 1003+ * Get the value count from the event. 1004+ * 1005+ * @param event The libinput_event_joystick_button 1006+ * @return The value for this event. 1007+ */ 1008+int libinput_event_joystick_button_get_value(struct libinput_event_joystick_button* event); 1009+ 1010+/** 1011+ * @ingroup config 1012+ * 1013+ * Get the pressure of the touch screen 1014+ * 1015+ * @param Carried libinput event 1016+ * @return Pressure value of touch screen 1017+ * 1018+ * @since 1.4 1019+ */ 1020+double 1021+libinput_event_touch_get_pressure(struct libinput_event_touch* event); 1022+ 1023+/** 1024+ * @ingroup event_touch 1025+ * 1026+ * Gets the long axis of the touch point region of the touch screen 1027+ * 1028+ * @param event The libinput touch event 1029+ * @return Long axis value of touch point region 1030+ */ 1031+int32_t 1032+libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event); 1033+ 1034+/** 1035+ * @ingroup event_touch 1036+ * 1037+ * Gets the short axis of the touch point region of the touch screen 1038+ * 1039+ * @param event The libinput touch event 1040+ * @return Short axis value of touch point region 1041+ */ 1042+int32_t 1043+libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event); 1044+ 1045+const char* 1046+libinput_device_get_phys(struct libinput_device* device); 1047+ 1048+const char* 1049+libinput_device_get_uniq(struct libinput_device* device); 1050+ 1051+enum libinput_button_state 1052+libinput_event_joystick_button_get_key_state(struct libinput_event_joystick_button* event); 1053 #ifdef __cplusplus 1054 } 1055 #endif 1056 #endif /* LIBINPUT_H */ 1057+ 1058diff -Naur old/hm_src/hm_missing.c new/hm_src/hm_missing.c 1059--- old/hm_src/hm_missing.c 1970-01-01 00:00:00.000000000 +0000 1060+++ new/hm_src/hm_missing.c 2021-01-01 00:00:00.000000000 +0000 1061@@ -0,0 +1,22 @@ 1062+/* 1063+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 1064+ * Licensed under the Apache License, Version 2.0 (the "License"); 1065+ * you may not use this file except in compliance with the License. 1066+ * You may obtain a copy of the License at 1067+ * 1068+ * http://www.apache.org/licenses/LICENSE-2.0 1069+ * 1070+ * Unless required by applicable law or agreed to in writing, software 1071+ * distributed under the License is distributed on an "AS IS" BASIS, 1072+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1073+ * See the License for the specific language governing permissions and 1074+ * limitations under the License. 1075+ */ 1076+ 1077+#include "hm_missing.h" 1078+ 1079+extern char *__progname; 1080+char *ohos_program_invocation_short_name() 1081+{ 1082+ return __progname; 1083+} 1084\ No newline at end of file 1085diff -Naur old/hm_src/hm_missing.h new/hm_src/hm_missing.h 1086--- old/hm_src/hm_missing.h 1970-01-01 00:00:00.000000000 +0000 1087+++ new/hm_src/hm_missing.h 2021-01-01 00:00:00.000000000 +0000 1088@@ -0,0 +1,25 @@ 1089+/* 1090+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 1091+ * Licensed under the Apache License, Version 2.0 (the "License"); 1092+ * you may not use this file except in compliance with the License. 1093+ * You may obtain a copy of the License at 1094+ * 1095+ * http://www.apache.org/licenses/LICENSE-2.0 1096+ * 1097+ * Unless required by applicable law or agreed to in writing, software 1098+ * distributed under the License is distributed on an "AS IS" BASIS, 1099+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1100+ * See the License for the specific language governing permissions and 1101+ * limitations under the License. 1102+ */ 1103+ 1104+#ifndef OHOS_LIBINPUT_HM_MISSING_H 1105+#define OHOS_LIBINPUT_HM_MISSING_H 1106+ 1107+/* The full and simple forms of the name with which the program was 1108+ invoked. These variables are set up automatically at startup based on 1109+ the value of argv[0]. */ 1110+extern char *ohos_program_invocation_short_name(); 1111+#define program_invocation_short_name ohos_program_invocation_short_name() 1112+ 1113+#endif 1114diff -Naur old/include/config.h new/include/config.h 1115--- old/include/config.h 2021-01-01 00:00:00.000000000 +0000 1116+++ new/include/config.h 2021-01-01 00:00:00.000000000 +0000 1117@@ -15,23 +15,41 @@ 1118 1119 #define HAVE_LIBSYSTEMD 0 1120 1121-#define HAVE_LIBWACOM 1 1122+#define HAVE_LIBWACOM 0 1123 1124 #define HAVE_LOCALE_H 1 1125 1126+#ifndef __MUSL__ 1127+#undef HAVE_VERSIONSORT 1128+#else 1129 #define HAVE_VERSIONSORT 1 1130- 1131+#endif 1132 #define HTTP_DOC_LINK "https://wayland.freedesktop.org/libinput/doc/1.19.4" 1133 1134-#define LIBINPUT_QUIRKS_DIR "/usr/share/libinput" 1135+#define LIBINPUT_QUIRKS_DIR "/etc/libinput/quirks" 1136+ 1137+#define LIBINPUT_QUIRKS_OVERRIDE_FILE "/etc/libinput/quirks/local-overrides.quirks" 1138+ 1139+#define LIBINPUT_QUIRKS_SRCDIR "/etc/libinput/quirks" 1140 1141-#define LIBINPUT_QUIRKS_OVERRIDE_FILE "/etc/libinput/local-overrides.quirks" 1142+#define LIBINPUT_TOOL_PATH "/data/libinput" 1143 1144-#define LIBINPUT_QUIRKS_SRCDIR "" 1145+#define MESON_BUILD_ROOT "/data/libinput" 1146 1147-#define LIBINPUT_TOOL_PATH "" 1148+#undef NDEBUG 1149+#ifndef static_assert 1150+# ifdef _Static_assert 1151+# define static_assert(cond, msg) _Static_assert(cond, msg) 1152+# else 1153+# define static_assert(cond, msg) 1154+# endif 1155+#endif 1156 1157-#define MESON_BUILD_ROOT "" 1158+#define index strchr 1159+#define ffs __builtin_ffs 1160 1161-#define _GNU_SOURCE 1 1162+#ifdef HAVE_LIBINPUT_LOG_ENABLE 1163+#define _LIBINPUT_LOG_DIR "/data/log/libinput" 1164+#define _LIBINPUT_LOG_PATH "/data/log/libinput/libinput.log" 1165+#endif 1166 1167diff -Naur old/include/linux/linux/input-event-codes.h new/include/linux/linux/input-event-codes.h 1168--- old/include/linux/linux/input-event-codes.h 2021-01-01 00:00:00.000000000 +0000 1169+++ new/include/linux/linux/input-event-codes.h 1970-01-01 00:00:00.000000000 +0000 1170@@ -1,945 +0,0 @@ 1171-/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ 1172-/* 1173- * Input event codes 1174- * 1175- * *** IMPORTANT *** 1176- * This file is not only included from C-code but also from devicetree source 1177- * files. As such this file MUST only contain comments and defines. 1178- * 1179- * Copyright (c) 1999-2002 Vojtech Pavlik 1180- * Copyright (c) 2015 Hans de Goede <hdegoede@redhat.com> 1181- * 1182- * This program is free software; you can redistribute it and/or modify it 1183- * under the terms of the GNU General Public License version 2 as published by 1184- * the Free Software Foundation. 1185- */ 1186-#ifndef _UAPI_INPUT_EVENT_CODES_H 1187-#define _UAPI_INPUT_EVENT_CODES_H 1188- 1189-/* 1190- * Device properties and quirks 1191- */ 1192- 1193-#define INPUT_PROP_POINTER 0x00 /* needs a pointer */ 1194-#define INPUT_PROP_DIRECT 0x01 /* direct input devices */ 1195-#define INPUT_PROP_BUTTONPAD 0x02 /* has button(s) under pad */ 1196-#define INPUT_PROP_SEMI_MT 0x03 /* touch rectangle only */ 1197-#define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ 1198-#define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ 1199-#define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ 1200- 1201-#define INPUT_PROP_MAX 0x1f 1202-#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) 1203- 1204-/* 1205- * Event types 1206- */ 1207- 1208-#define EV_SYN 0x00 1209-#define EV_KEY 0x01 1210-#define EV_REL 0x02 1211-#define EV_ABS 0x03 1212-#define EV_MSC 0x04 1213-#define EV_SW 0x05 1214-#define EV_LED 0x11 1215-#define EV_SND 0x12 1216-#define EV_REP 0x14 1217-#define EV_FF 0x15 1218-#define EV_PWR 0x16 1219-#define EV_FF_STATUS 0x17 1220-#define EV_MAX 0x1f 1221-#define EV_CNT (EV_MAX+1) 1222- 1223-/* 1224- * Synchronization events. 1225- */ 1226- 1227-#define SYN_REPORT 0 1228-#define SYN_CONFIG 1 1229-#define SYN_MT_REPORT 2 1230-#define SYN_DROPPED 3 1231-#define SYN_MAX 0xf 1232-#define SYN_CNT (SYN_MAX+1) 1233- 1234-/* 1235- * Keys and buttons 1236- * 1237- * Most of the keys/buttons are modeled after USB HUT 1.12 1238- * (see http://www.usb.org/developers/hidpage). 1239- * Abbreviations in the comments: 1240- * AC - Application Control 1241- * AL - Application Launch Button 1242- * SC - System Control 1243- */ 1244- 1245-#define KEY_RESERVED 0 1246-#define KEY_ESC 1 1247-#define KEY_1 2 1248-#define KEY_2 3 1249-#define KEY_3 4 1250-#define KEY_4 5 1251-#define KEY_5 6 1252-#define KEY_6 7 1253-#define KEY_7 8 1254-#define KEY_8 9 1255-#define KEY_9 10 1256-#define KEY_0 11 1257-#define KEY_MINUS 12 1258-#define KEY_EQUAL 13 1259-#define KEY_BACKSPACE 14 1260-#define KEY_TAB 15 1261-#define KEY_Q 16 1262-#define KEY_W 17 1263-#define KEY_E 18 1264-#define KEY_R 19 1265-#define KEY_T 20 1266-#define KEY_Y 21 1267-#define KEY_U 22 1268-#define KEY_I 23 1269-#define KEY_O 24 1270-#define KEY_P 25 1271-#define KEY_LEFTBRACE 26 1272-#define KEY_RIGHTBRACE 27 1273-#define KEY_ENTER 28 1274-#define KEY_LEFTCTRL 29 1275-#define KEY_A 30 1276-#define KEY_S 31 1277-#define KEY_D 32 1278-#define KEY_F 33 1279-#define KEY_G 34 1280-#define KEY_H 35 1281-#define KEY_J 36 1282-#define KEY_K 37 1283-#define KEY_L 38 1284-#define KEY_SEMICOLON 39 1285-#define KEY_APOSTROPHE 40 1286-#define KEY_GRAVE 41 1287-#define KEY_LEFTSHIFT 42 1288-#define KEY_BACKSLASH 43 1289-#define KEY_Z 44 1290-#define KEY_X 45 1291-#define KEY_C 46 1292-#define KEY_V 47 1293-#define KEY_B 48 1294-#define KEY_N 49 1295-#define KEY_M 50 1296-#define KEY_COMMA 51 1297-#define KEY_DOT 52 1298-#define KEY_SLASH 53 1299-#define KEY_RIGHTSHIFT 54 1300-#define KEY_KPASTERISK 55 1301-#define KEY_LEFTALT 56 1302-#define KEY_SPACE 57 1303-#define KEY_CAPSLOCK 58 1304-#define KEY_F1 59 1305-#define KEY_F2 60 1306-#define KEY_F3 61 1307-#define KEY_F4 62 1308-#define KEY_F5 63 1309-#define KEY_F6 64 1310-#define KEY_F7 65 1311-#define KEY_F8 66 1312-#define KEY_F9 67 1313-#define KEY_F10 68 1314-#define KEY_NUMLOCK 69 1315-#define KEY_SCROLLLOCK 70 1316-#define KEY_KP7 71 1317-#define KEY_KP8 72 1318-#define KEY_KP9 73 1319-#define KEY_KPMINUS 74 1320-#define KEY_KP4 75 1321-#define KEY_KP5 76 1322-#define KEY_KP6 77 1323-#define KEY_KPPLUS 78 1324-#define KEY_KP1 79 1325-#define KEY_KP2 80 1326-#define KEY_KP3 81 1327-#define KEY_KP0 82 1328-#define KEY_KPDOT 83 1329- 1330-#define KEY_ZENKAKUHANKAKU 85 1331-#define KEY_102ND 86 1332-#define KEY_F11 87 1333-#define KEY_F12 88 1334-#define KEY_RO 89 1335-#define KEY_KATAKANA 90 1336-#define KEY_HIRAGANA 91 1337-#define KEY_HENKAN 92 1338-#define KEY_KATAKANAHIRAGANA 93 1339-#define KEY_MUHENKAN 94 1340-#define KEY_KPJPCOMMA 95 1341-#define KEY_KPENTER 96 1342-#define KEY_RIGHTCTRL 97 1343-#define KEY_KPSLASH 98 1344-#define KEY_SYSRQ 99 1345-#define KEY_RIGHTALT 100 1346-#define KEY_LINEFEED 101 1347-#define KEY_HOME 102 1348-#define KEY_UP 103 1349-#define KEY_PAGEUP 104 1350-#define KEY_LEFT 105 1351-#define KEY_RIGHT 106 1352-#define KEY_END 107 1353-#define KEY_DOWN 108 1354-#define KEY_PAGEDOWN 109 1355-#define KEY_INSERT 110 1356-#define KEY_DELETE 111 1357-#define KEY_MACRO 112 1358-#define KEY_MUTE 113 1359-#define KEY_VOLUMEDOWN 114 1360-#define KEY_VOLUMEUP 115 1361-#define KEY_POWER 116 /* SC System Power Down */ 1362-#define KEY_KPEQUAL 117 1363-#define KEY_KPPLUSMINUS 118 1364-#define KEY_PAUSE 119 1365-#define KEY_SCALE 120 /* AL Compiz Scale (Expose) */ 1366- 1367-#define KEY_KPCOMMA 121 1368-#define KEY_HANGEUL 122 1369-#define KEY_HANGUEL KEY_HANGEUL 1370-#define KEY_HANJA 123 1371-#define KEY_YEN 124 1372-#define KEY_LEFTMETA 125 1373-#define KEY_RIGHTMETA 126 1374-#define KEY_COMPOSE 127 1375- 1376-#define KEY_STOP 128 /* AC Stop */ 1377-#define KEY_AGAIN 129 1378-#define KEY_PROPS 130 /* AC Properties */ 1379-#define KEY_UNDO 131 /* AC Undo */ 1380-#define KEY_FRONT 132 1381-#define KEY_COPY 133 /* AC Copy */ 1382-#define KEY_OPEN 134 /* AC Open */ 1383-#define KEY_PASTE 135 /* AC Paste */ 1384-#define KEY_FIND 136 /* AC Search */ 1385-#define KEY_CUT 137 /* AC Cut */ 1386-#define KEY_HELP 138 /* AL Integrated Help Center */ 1387-#define KEY_MENU 139 /* Menu (show menu) */ 1388-#define KEY_CALC 140 /* AL Calculator */ 1389-#define KEY_SETUP 141 1390-#define KEY_SLEEP 142 /* SC System Sleep */ 1391-#define KEY_WAKEUP 143 /* System Wake Up */ 1392-#define KEY_FILE 144 /* AL Local Machine Browser */ 1393-#define KEY_SENDFILE 145 1394-#define KEY_DELETEFILE 146 1395-#define KEY_XFER 147 1396-#define KEY_PROG1 148 1397-#define KEY_PROG2 149 1398-#define KEY_WWW 150 /* AL Internet Browser */ 1399-#define KEY_MSDOS 151 1400-#define KEY_COFFEE 152 /* AL Terminal Lock/Screensaver */ 1401-#define KEY_SCREENLOCK KEY_COFFEE 1402-#define KEY_ROTATE_DISPLAY 153 /* Display orientation for e.g. tablets */ 1403-#define KEY_DIRECTION KEY_ROTATE_DISPLAY 1404-#define KEY_CYCLEWINDOWS 154 1405-#define KEY_MAIL 155 1406-#define KEY_BOOKMARKS 156 /* AC Bookmarks */ 1407-#define KEY_COMPUTER 157 1408-#define KEY_BACK 158 /* AC Back */ 1409-#define KEY_FORWARD 159 /* AC Forward */ 1410-#define KEY_CLOSECD 160 1411-#define KEY_EJECTCD 161 1412-#define KEY_EJECTCLOSECD 162 1413-#define KEY_NEXTSONG 163 1414-#define KEY_PLAYPAUSE 164 1415-#define KEY_PREVIOUSSONG 165 1416-#define KEY_STOPCD 166 1417-#define KEY_RECORD 167 1418-#define KEY_REWIND 168 1419-#define KEY_PHONE 169 /* Media Select Telephone */ 1420-#define KEY_ISO 170 1421-#define KEY_CONFIG 171 /* AL Consumer Control Configuration */ 1422-#define KEY_HOMEPAGE 172 /* AC Home */ 1423-#define KEY_REFRESH 173 /* AC Refresh */ 1424-#define KEY_EXIT 174 /* AC Exit */ 1425-#define KEY_MOVE 175 1426-#define KEY_EDIT 176 1427-#define KEY_SCROLLUP 177 1428-#define KEY_SCROLLDOWN 178 1429-#define KEY_KPLEFTPAREN 179 1430-#define KEY_KPRIGHTPAREN 180 1431-#define KEY_NEW 181 /* AC New */ 1432-#define KEY_REDO 182 /* AC Redo/Repeat */ 1433- 1434-#define KEY_F13 183 1435-#define KEY_F14 184 1436-#define KEY_F15 185 1437-#define KEY_F16 186 1438-#define KEY_F17 187 1439-#define KEY_F18 188 1440-#define KEY_F19 189 1441-#define KEY_F20 190 1442-#define KEY_F21 191 1443-#define KEY_F22 192 1444-#define KEY_F23 193 1445-#define KEY_F24 194 1446- 1447-#define KEY_PLAYCD 200 1448-#define KEY_PAUSECD 201 1449-#define KEY_PROG3 202 1450-#define KEY_PROG4 203 1451-#define KEY_DASHBOARD 204 /* AL Dashboard */ 1452-#define KEY_SUSPEND 205 1453-#define KEY_CLOSE 206 /* AC Close */ 1454-#define KEY_PLAY 207 1455-#define KEY_FASTFORWARD 208 1456-#define KEY_BASSBOOST 209 1457-#define KEY_PRINT 210 /* AC Print */ 1458-#define KEY_HP 211 1459-#define KEY_CAMERA 212 1460-#define KEY_SOUND 213 1461-#define KEY_QUESTION 214 1462-#define KEY_EMAIL 215 1463-#define KEY_CHAT 216 1464-#define KEY_SEARCH 217 1465-#define KEY_CONNECT 218 1466-#define KEY_FINANCE 219 /* AL Checkbook/Finance */ 1467-#define KEY_SPORT 220 1468-#define KEY_SHOP 221 1469-#define KEY_ALTERASE 222 1470-#define KEY_CANCEL 223 /* AC Cancel */ 1471-#define KEY_BRIGHTNESSDOWN 224 1472-#define KEY_BRIGHTNESSUP 225 1473-#define KEY_MEDIA 226 1474- 1475-#define KEY_SWITCHVIDEOMODE 227 /* Cycle between available video 1476- outputs (Monitor/LCD/TV-out/etc) */ 1477-#define KEY_KBDILLUMTOGGLE 228 1478-#define KEY_KBDILLUMDOWN 229 1479-#define KEY_KBDILLUMUP 230 1480- 1481-#define KEY_SEND 231 /* AC Send */ 1482-#define KEY_REPLY 232 /* AC Reply */ 1483-#define KEY_FORWARDMAIL 233 /* AC Forward Msg */ 1484-#define KEY_SAVE 234 /* AC Save */ 1485-#define KEY_DOCUMENTS 235 1486- 1487-#define KEY_BATTERY 236 1488- 1489-#define KEY_BLUETOOTH 237 1490-#define KEY_WLAN 238 1491-#define KEY_UWB 239 1492- 1493-#define KEY_UNKNOWN 240 1494- 1495-#define KEY_VIDEO_NEXT 241 /* drive next video source */ 1496-#define KEY_VIDEO_PREV 242 /* drive previous video source */ 1497-#define KEY_BRIGHTNESS_CYCLE 243 /* brightness up, after max is min */ 1498-#define KEY_BRIGHTNESS_AUTO 244 /* Set Auto Brightness: manual 1499- brightness control is off, 1500- rely on ambient */ 1501-#define KEY_BRIGHTNESS_ZERO KEY_BRIGHTNESS_AUTO 1502-#define KEY_DISPLAY_OFF 245 /* display device to off state */ 1503- 1504-#define KEY_WWAN 246 /* Wireless WAN (LTE, UMTS, GSM, etc.) */ 1505-#define KEY_WIMAX KEY_WWAN 1506-#define KEY_RFKILL 247 /* Key that controls all radios */ 1507- 1508-#define KEY_MICMUTE 248 /* Mute / unmute the microphone */ 1509- 1510-/* Code 255 is reserved for special needs of AT keyboard driver */ 1511- 1512-#define BTN_MISC 0x100 1513-#define BTN_0 0x100 1514-#define BTN_1 0x101 1515-#define BTN_2 0x102 1516-#define BTN_3 0x103 1517-#define BTN_4 0x104 1518-#define BTN_5 0x105 1519-#define BTN_6 0x106 1520-#define BTN_7 0x107 1521-#define BTN_8 0x108 1522-#define BTN_9 0x109 1523- 1524-#define BTN_MOUSE 0x110 1525-#define BTN_LEFT 0x110 1526-#define BTN_RIGHT 0x111 1527-#define BTN_MIDDLE 0x112 1528-#define BTN_SIDE 0x113 1529-#define BTN_EXTRA 0x114 1530-#define BTN_FORWARD 0x115 1531-#define BTN_BACK 0x116 1532-#define BTN_TASK 0x117 1533- 1534-#define BTN_JOYSTICK 0x120 1535-#define BTN_TRIGGER 0x120 1536-#define BTN_THUMB 0x121 1537-#define BTN_THUMB2 0x122 1538-#define BTN_TOP 0x123 1539-#define BTN_TOP2 0x124 1540-#define BTN_PINKIE 0x125 1541-#define BTN_BASE 0x126 1542-#define BTN_BASE2 0x127 1543-#define BTN_BASE3 0x128 1544-#define BTN_BASE4 0x129 1545-#define BTN_BASE5 0x12a 1546-#define BTN_BASE6 0x12b 1547-#define BTN_DEAD 0x12f 1548- 1549-#define BTN_GAMEPAD 0x130 1550-#define BTN_SOUTH 0x130 1551-#define BTN_A BTN_SOUTH 1552-#define BTN_EAST 0x131 1553-#define BTN_B BTN_EAST 1554-#define BTN_C 0x132 1555-#define BTN_NORTH 0x133 1556-#define BTN_X BTN_NORTH 1557-#define BTN_WEST 0x134 1558-#define BTN_Y BTN_WEST 1559-#define BTN_Z 0x135 1560-#define BTN_TL 0x136 1561-#define BTN_TR 0x137 1562-#define BTN_TL2 0x138 1563-#define BTN_TR2 0x139 1564-#define BTN_SELECT 0x13a 1565-#define BTN_START 0x13b 1566-#define BTN_MODE 0x13c 1567-#define BTN_THUMBL 0x13d 1568-#define BTN_THUMBR 0x13e 1569- 1570-#define BTN_DIGI 0x140 1571-#define BTN_TOOL_PEN 0x140 1572-#define BTN_TOOL_RUBBER 0x141 1573-#define BTN_TOOL_BRUSH 0x142 1574-#define BTN_TOOL_PENCIL 0x143 1575-#define BTN_TOOL_AIRBRUSH 0x144 1576-#define BTN_TOOL_FINGER 0x145 1577-#define BTN_TOOL_MOUSE 0x146 1578-#define BTN_TOOL_LENS 0x147 1579-#define BTN_TOOL_QUINTTAP 0x148 /* Five fingers on trackpad */ 1580-#define BTN_STYLUS3 0x149 1581-#define BTN_TOUCH 0x14a 1582-#define BTN_STYLUS 0x14b 1583-#define BTN_STYLUS2 0x14c 1584-#define BTN_TOOL_DOUBLETAP 0x14d 1585-#define BTN_TOOL_TRIPLETAP 0x14e 1586-#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ 1587- 1588-#define BTN_WHEEL 0x150 1589-#define BTN_GEAR_DOWN 0x150 1590-#define BTN_GEAR_UP 0x151 1591- 1592-#define KEY_OK 0x160 1593-#define KEY_SELECT 0x161 1594-#define KEY_GOTO 0x162 1595-#define KEY_CLEAR 0x163 1596-#define KEY_POWER2 0x164 1597-#define KEY_OPTION 0x165 1598-#define KEY_INFO 0x166 /* AL OEM Features/Tips/Tutorial */ 1599-#define KEY_TIME 0x167 1600-#define KEY_VENDOR 0x168 1601-#define KEY_ARCHIVE 0x169 1602-#define KEY_PROGRAM 0x16a /* Media Select Program Guide */ 1603-#define KEY_CHANNEL 0x16b 1604-#define KEY_FAVORITES 0x16c 1605-#define KEY_EPG 0x16d 1606-#define KEY_PVR 0x16e /* Media Select Home */ 1607-#define KEY_MHP 0x16f 1608-#define KEY_LANGUAGE 0x170 1609-#define KEY_TITLE 0x171 1610-#define KEY_SUBTITLE 0x172 1611-#define KEY_ANGLE 0x173 1612-#define KEY_FULL_SCREEN 0x174 /* AC View Toggle */ 1613-#define KEY_ZOOM KEY_FULL_SCREEN 1614-#define KEY_MODE 0x175 1615-#define KEY_KEYBOARD 0x176 1616-#define KEY_ASPECT_RATIO 0x177 /* HUTRR37: Aspect */ 1617-#define KEY_SCREEN KEY_ASPECT_RATIO 1618-#define KEY_PC 0x178 /* Media Select Computer */ 1619-#define KEY_TV 0x179 /* Media Select TV */ 1620-#define KEY_TV2 0x17a /* Media Select Cable */ 1621-#define KEY_VCR 0x17b /* Media Select VCR */ 1622-#define KEY_VCR2 0x17c /* VCR Plus */ 1623-#define KEY_SAT 0x17d /* Media Select Satellite */ 1624-#define KEY_SAT2 0x17e 1625-#define KEY_CD 0x17f /* Media Select CD */ 1626-#define KEY_TAPE 0x180 /* Media Select Tape */ 1627-#define KEY_RADIO 0x181 1628-#define KEY_TUNER 0x182 /* Media Select Tuner */ 1629-#define KEY_PLAYER 0x183 1630-#define KEY_TEXT 0x184 1631-#define KEY_DVD 0x185 /* Media Select DVD */ 1632-#define KEY_AUX 0x186 1633-#define KEY_MP3 0x187 1634-#define KEY_AUDIO 0x188 /* AL Audio Browser */ 1635-#define KEY_VIDEO 0x189 /* AL Movie Browser */ 1636-#define KEY_DIRECTORY 0x18a 1637-#define KEY_LIST 0x18b 1638-#define KEY_MEMO 0x18c /* Media Select Messages */ 1639-#define KEY_CALENDAR 0x18d 1640-#define KEY_RED 0x18e 1641-#define KEY_GREEN 0x18f 1642-#define KEY_YELLOW 0x190 1643-#define KEY_BLUE 0x191 1644-#define KEY_CHANNELUP 0x192 /* Channel Increment */ 1645-#define KEY_CHANNELDOWN 0x193 /* Channel Decrement */ 1646-#define KEY_FIRST 0x194 1647-#define KEY_LAST 0x195 /* Recall Last */ 1648-#define KEY_AB 0x196 1649-#define KEY_NEXT 0x197 1650-#define KEY_RESTART 0x198 1651-#define KEY_SLOW 0x199 1652-#define KEY_SHUFFLE 0x19a 1653-#define KEY_BREAK 0x19b 1654-#define KEY_PREVIOUS 0x19c 1655-#define KEY_DIGITS 0x19d 1656-#define KEY_TEEN 0x19e 1657-#define KEY_TWEN 0x19f 1658-#define KEY_VIDEOPHONE 0x1a0 /* Media Select Video Phone */ 1659-#define KEY_GAMES 0x1a1 /* Media Select Games */ 1660-#define KEY_ZOOMIN 0x1a2 /* AC Zoom In */ 1661-#define KEY_ZOOMOUT 0x1a3 /* AC Zoom Out */ 1662-#define KEY_ZOOMRESET 0x1a4 /* AC Zoom */ 1663-#define KEY_WORDPROCESSOR 0x1a5 /* AL Word Processor */ 1664-#define KEY_EDITOR 0x1a6 /* AL Text Editor */ 1665-#define KEY_SPREADSHEET 0x1a7 /* AL Spreadsheet */ 1666-#define KEY_GRAPHICSEDITOR 0x1a8 /* AL Graphics Editor */ 1667-#define KEY_PRESENTATION 0x1a9 /* AL Presentation App */ 1668-#define KEY_DATABASE 0x1aa /* AL Database App */ 1669-#define KEY_NEWS 0x1ab /* AL Newsreader */ 1670-#define KEY_VOICEMAIL 0x1ac /* AL Voicemail */ 1671-#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ 1672-#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ 1673-#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ 1674-#define KEY_BRIGHTNESS_TOGGLE KEY_DISPLAYTOGGLE 1675-#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ 1676-#define KEY_LOGOFF 0x1b1 /* AL Logoff */ 1677- 1678-#define KEY_DOLLAR 0x1b2 1679-#define KEY_EURO 0x1b3 1680- 1681-#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */ 1682-#define KEY_FRAMEFORWARD 0x1b5 1683-#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */ 1684-#define KEY_MEDIA_REPEAT 0x1b7 /* Consumer - transport control */ 1685-#define KEY_10CHANNELSUP 0x1b8 /* 10 channels up (10+) */ 1686-#define KEY_10CHANNELSDOWN 0x1b9 /* 10 channels down (10-) */ 1687-#define KEY_IMAGES 0x1ba /* AL Image Browser */ 1688- 1689-#define KEY_DEL_EOL 0x1c0 1690-#define KEY_DEL_EOS 0x1c1 1691-#define KEY_INS_LINE 0x1c2 1692-#define KEY_DEL_LINE 0x1c3 1693- 1694-#define KEY_FN 0x1d0 1695-#define KEY_FN_ESC 0x1d1 1696-#define KEY_FN_F1 0x1d2 1697-#define KEY_FN_F2 0x1d3 1698-#define KEY_FN_F3 0x1d4 1699-#define KEY_FN_F4 0x1d5 1700-#define KEY_FN_F5 0x1d6 1701-#define KEY_FN_F6 0x1d7 1702-#define KEY_FN_F7 0x1d8 1703-#define KEY_FN_F8 0x1d9 1704-#define KEY_FN_F9 0x1da 1705-#define KEY_FN_F10 0x1db 1706-#define KEY_FN_F11 0x1dc 1707-#define KEY_FN_F12 0x1dd 1708-#define KEY_FN_1 0x1de 1709-#define KEY_FN_2 0x1df 1710-#define KEY_FN_D 0x1e0 1711-#define KEY_FN_E 0x1e1 1712-#define KEY_FN_F 0x1e2 1713-#define KEY_FN_S 0x1e3 1714-#define KEY_FN_B 0x1e4 1715- 1716-#define KEY_BRL_DOT1 0x1f1 1717-#define KEY_BRL_DOT2 0x1f2 1718-#define KEY_BRL_DOT3 0x1f3 1719-#define KEY_BRL_DOT4 0x1f4 1720-#define KEY_BRL_DOT5 0x1f5 1721-#define KEY_BRL_DOT6 0x1f6 1722-#define KEY_BRL_DOT7 0x1f7 1723-#define KEY_BRL_DOT8 0x1f8 1724-#define KEY_BRL_DOT9 0x1f9 1725-#define KEY_BRL_DOT10 0x1fa 1726- 1727-#define KEY_NUMERIC_0 0x200 /* used by phones, remote controls, */ 1728-#define KEY_NUMERIC_1 0x201 /* and other keypads */ 1729-#define KEY_NUMERIC_2 0x202 1730-#define KEY_NUMERIC_3 0x203 1731-#define KEY_NUMERIC_4 0x204 1732-#define KEY_NUMERIC_5 0x205 1733-#define KEY_NUMERIC_6 0x206 1734-#define KEY_NUMERIC_7 0x207 1735-#define KEY_NUMERIC_8 0x208 1736-#define KEY_NUMERIC_9 0x209 1737-#define KEY_NUMERIC_STAR 0x20a 1738-#define KEY_NUMERIC_POUND 0x20b 1739-#define KEY_NUMERIC_A 0x20c /* Phone key A - HUT Telephony 0xb9 */ 1740-#define KEY_NUMERIC_B 0x20d 1741-#define KEY_NUMERIC_C 0x20e 1742-#define KEY_NUMERIC_D 0x20f 1743- 1744-#define KEY_CAMERA_FOCUS 0x210 1745-#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ 1746- 1747-#define KEY_TOUCHPAD_TOGGLE 0x212 /* Request switch touchpad on or off */ 1748-#define KEY_TOUCHPAD_ON 0x213 1749-#define KEY_TOUCHPAD_OFF 0x214 1750- 1751-#define KEY_CAMERA_ZOOMIN 0x215 1752-#define KEY_CAMERA_ZOOMOUT 0x216 1753-#define KEY_CAMERA_UP 0x217 1754-#define KEY_CAMERA_DOWN 0x218 1755-#define KEY_CAMERA_LEFT 0x219 1756-#define KEY_CAMERA_RIGHT 0x21a 1757- 1758-#define KEY_ATTENDANT_ON 0x21b 1759-#define KEY_ATTENDANT_OFF 0x21c 1760-#define KEY_ATTENDANT_TOGGLE 0x21d /* Attendant call on or off */ 1761-#define KEY_LIGHTS_TOGGLE 0x21e /* Reading light on or off */ 1762- 1763-#define BTN_DPAD_UP 0x220 1764-#define BTN_DPAD_DOWN 0x221 1765-#define BTN_DPAD_LEFT 0x222 1766-#define BTN_DPAD_RIGHT 0x223 1767- 1768-#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ 1769-#define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ 1770- 1771-#define KEY_BUTTONCONFIG 0x240 /* AL Button Configuration */ 1772-#define KEY_TASKMANAGER 0x241 /* AL Task/Project Manager */ 1773-#define KEY_JOURNAL 0x242 /* AL Log/Journal/Timecard */ 1774-#define KEY_CONTROLPANEL 0x243 /* AL Control Panel */ 1775-#define KEY_APPSELECT 0x244 /* AL Select Task/Application */ 1776-#define KEY_SCREENSAVER 0x245 /* AL Screen Saver */ 1777-#define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ 1778-#define KEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */ 1779-#define KEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */ 1780- 1781-#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ 1782-#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ 1783- 1784-#define KEY_KBDINPUTASSIST_PREV 0x260 1785-#define KEY_KBDINPUTASSIST_NEXT 0x261 1786-#define KEY_KBDINPUTASSIST_PREVGROUP 0x262 1787-#define KEY_KBDINPUTASSIST_NEXTGROUP 0x263 1788-#define KEY_KBDINPUTASSIST_ACCEPT 0x264 1789-#define KEY_KBDINPUTASSIST_CANCEL 0x265 1790- 1791-/* Diagonal movement keys */ 1792-#define KEY_RIGHT_UP 0x266 1793-#define KEY_RIGHT_DOWN 0x267 1794-#define KEY_LEFT_UP 0x268 1795-#define KEY_LEFT_DOWN 0x269 1796- 1797-#define KEY_ROOT_MENU 0x26a /* Show Device's Root Menu */ 1798-/* Show Top Menu of the Media (e.g. DVD) */ 1799-#define KEY_MEDIA_TOP_MENU 0x26b 1800-#define KEY_NUMERIC_11 0x26c 1801-#define KEY_NUMERIC_12 0x26d 1802-/* 1803- * Toggle Audio Description: refers to an audio service that helps blind and 1804- * visually impaired consumers understand the action in a program. Note: in 1805- * some countries this is referred to as "Video Description". 1806- */ 1807-#define KEY_AUDIO_DESC 0x26e 1808-#define KEY_3D_MODE 0x26f 1809-#define KEY_NEXT_FAVORITE 0x270 1810-#define KEY_STOP_RECORD 0x271 1811-#define KEY_PAUSE_RECORD 0x272 1812-#define KEY_VOD 0x273 /* Video on Demand */ 1813-#define KEY_UNMUTE 0x274 1814-#define KEY_FASTREVERSE 0x275 1815-#define KEY_SLOWREVERSE 0x276 1816-/* 1817- * Control a data application associated with the currently viewed channel, 1818- * e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.) 1819- */ 1820-#define KEY_DATA 0x277 1821-#define KEY_ONSCREEN_KEYBOARD 0x278 1822-/* Electronic privacy screen control */ 1823-#define KEY_PRIVACY_SCREEN_TOGGLE 0x279 1824- 1825-/* Select an area of screen to be copied */ 1826-#define KEY_SELECTIVE_SCREENSHOT 0x27a 1827- 1828-/* 1829- * Some keyboards have keys which do not have a defined meaning, these keys 1830- * are intended to be programmed / bound to macros by the user. For most 1831- * keyboards with these macro-keys the key-sequence to inject, or action to 1832- * take, is all handled by software on the host side. So from the kernel's 1833- * point of view these are just normal keys. 1834- * 1835- * The KEY_MACRO# codes below are intended for such keys, which may be labeled 1836- * e.g. G1-G18, or S1 - S30. The KEY_MACRO# codes MUST NOT be used for keys 1837- * where the marking on the key does indicate a defined meaning / purpose. 1838- * 1839- * The KEY_MACRO# codes MUST also NOT be used as fallback for when no existing 1840- * KEY_FOO define matches the marking / purpose. In this case a new KEY_FOO 1841- * define MUST be added. 1842- */ 1843-#define KEY_MACRO1 0x290 1844-#define KEY_MACRO2 0x291 1845-#define KEY_MACRO3 0x292 1846-#define KEY_MACRO4 0x293 1847-#define KEY_MACRO5 0x294 1848-#define KEY_MACRO6 0x295 1849-#define KEY_MACRO7 0x296 1850-#define KEY_MACRO8 0x297 1851-#define KEY_MACRO9 0x298 1852-#define KEY_MACRO10 0x299 1853-#define KEY_MACRO11 0x29a 1854-#define KEY_MACRO12 0x29b 1855-#define KEY_MACRO13 0x29c 1856-#define KEY_MACRO14 0x29d 1857-#define KEY_MACRO15 0x29e 1858-#define KEY_MACRO16 0x29f 1859-#define KEY_MACRO17 0x2a0 1860-#define KEY_MACRO18 0x2a1 1861-#define KEY_MACRO19 0x2a2 1862-#define KEY_MACRO20 0x2a3 1863-#define KEY_MACRO21 0x2a4 1864-#define KEY_MACRO22 0x2a5 1865-#define KEY_MACRO23 0x2a6 1866-#define KEY_MACRO24 0x2a7 1867-#define KEY_MACRO25 0x2a8 1868-#define KEY_MACRO26 0x2a9 1869-#define KEY_MACRO27 0x2aa 1870-#define KEY_MACRO28 0x2ab 1871-#define KEY_MACRO29 0x2ac 1872-#define KEY_MACRO30 0x2ad 1873- 1874-/* 1875- * Some keyboards with the macro-keys described above have some extra keys 1876- * for controlling the host-side software responsible for the macro handling: 1877- * -A macro recording start/stop key. Note that not all keyboards which emit 1878- * KEY_MACRO_RECORD_START will also emit KEY_MACRO_RECORD_STOP if 1879- * KEY_MACRO_RECORD_STOP is not advertised, then KEY_MACRO_RECORD_START 1880- * should be interpreted as a recording start/stop toggle; 1881- * -Keys for switching between different macro (pre)sets, either a key for 1882- * cycling through the configured presets or keys to directly select a preset. 1883- */ 1884-#define KEY_MACRO_RECORD_START 0x2b0 1885-#define KEY_MACRO_RECORD_STOP 0x2b1 1886-#define KEY_MACRO_PRESET_CYCLE 0x2b2 1887-#define KEY_MACRO_PRESET1 0x2b3 1888-#define KEY_MACRO_PRESET2 0x2b4 1889-#define KEY_MACRO_PRESET3 0x2b5 1890- 1891-/* 1892- * Some keyboards have a buildin LCD panel where the contents are controlled 1893- * by the host. Often these have a number of keys directly below the LCD 1894- * intended for controlling a menu shown on the LCD. These keys often don't 1895- * have any labeling so we just name them KEY_KBD_LCD_MENU# 1896- */ 1897-#define KEY_KBD_LCD_MENU1 0x2b8 1898-#define KEY_KBD_LCD_MENU2 0x2b9 1899-#define KEY_KBD_LCD_MENU3 0x2ba 1900-#define KEY_KBD_LCD_MENU4 0x2bb 1901-#define KEY_KBD_LCD_MENU5 0x2bc 1902- 1903-#define BTN_TRIGGER_HAPPY 0x2c0 1904-#define BTN_TRIGGER_HAPPY1 0x2c0 1905-#define BTN_TRIGGER_HAPPY2 0x2c1 1906-#define BTN_TRIGGER_HAPPY3 0x2c2 1907-#define BTN_TRIGGER_HAPPY4 0x2c3 1908-#define BTN_TRIGGER_HAPPY5 0x2c4 1909-#define BTN_TRIGGER_HAPPY6 0x2c5 1910-#define BTN_TRIGGER_HAPPY7 0x2c6 1911-#define BTN_TRIGGER_HAPPY8 0x2c7 1912-#define BTN_TRIGGER_HAPPY9 0x2c8 1913-#define BTN_TRIGGER_HAPPY10 0x2c9 1914-#define BTN_TRIGGER_HAPPY11 0x2ca 1915-#define BTN_TRIGGER_HAPPY12 0x2cb 1916-#define BTN_TRIGGER_HAPPY13 0x2cc 1917-#define BTN_TRIGGER_HAPPY14 0x2cd 1918-#define BTN_TRIGGER_HAPPY15 0x2ce 1919-#define BTN_TRIGGER_HAPPY16 0x2cf 1920-#define BTN_TRIGGER_HAPPY17 0x2d0 1921-#define BTN_TRIGGER_HAPPY18 0x2d1 1922-#define BTN_TRIGGER_HAPPY19 0x2d2 1923-#define BTN_TRIGGER_HAPPY20 0x2d3 1924-#define BTN_TRIGGER_HAPPY21 0x2d4 1925-#define BTN_TRIGGER_HAPPY22 0x2d5 1926-#define BTN_TRIGGER_HAPPY23 0x2d6 1927-#define BTN_TRIGGER_HAPPY24 0x2d7 1928-#define BTN_TRIGGER_HAPPY25 0x2d8 1929-#define BTN_TRIGGER_HAPPY26 0x2d9 1930-#define BTN_TRIGGER_HAPPY27 0x2da 1931-#define BTN_TRIGGER_HAPPY28 0x2db 1932-#define BTN_TRIGGER_HAPPY29 0x2dc 1933-#define BTN_TRIGGER_HAPPY30 0x2dd 1934-#define BTN_TRIGGER_HAPPY31 0x2de 1935-#define BTN_TRIGGER_HAPPY32 0x2df 1936-#define BTN_TRIGGER_HAPPY33 0x2e0 1937-#define BTN_TRIGGER_HAPPY34 0x2e1 1938-#define BTN_TRIGGER_HAPPY35 0x2e2 1939-#define BTN_TRIGGER_HAPPY36 0x2e3 1940-#define BTN_TRIGGER_HAPPY37 0x2e4 1941-#define BTN_TRIGGER_HAPPY38 0x2e5 1942-#define BTN_TRIGGER_HAPPY39 0x2e6 1943-#define BTN_TRIGGER_HAPPY40 0x2e7 1944- 1945-/* We avoid low common keys in module aliases so they don't get huge. */ 1946-#define KEY_MIN_INTERESTING KEY_MUTE 1947-#define KEY_MAX 0x2ff 1948-#define KEY_CNT (KEY_MAX+1) 1949- 1950-/* 1951- * Relative axes 1952- */ 1953- 1954-#define REL_X 0x00 1955-#define REL_Y 0x01 1956-#define REL_Z 0x02 1957-#define REL_RX 0x03 1958-#define REL_RY 0x04 1959-#define REL_RZ 0x05 1960-#define REL_HWHEEL 0x06 1961-#define REL_DIAL 0x07 1962-#define REL_WHEEL 0x08 1963-#define REL_MISC 0x09 1964-/* 1965- * 0x0a is reserved and should not be used in input drivers. 1966- * It was used by HID as REL_MISC+1 and userspace needs to detect if 1967- * the next REL_* event is correct or is just REL_MISC + n. 1968- * We define here REL_RESERVED so userspace can rely on it and detect 1969- * the situation described above. 1970- */ 1971-#define REL_RESERVED 0x0a 1972-#define REL_WHEEL_HI_RES 0x0b 1973-#define REL_HWHEEL_HI_RES 0x0c 1974-#define REL_MAX 0x0f 1975-#define REL_CNT (REL_MAX+1) 1976- 1977-/* 1978- * Absolute axes 1979- */ 1980- 1981-#define ABS_X 0x00 1982-#define ABS_Y 0x01 1983-#define ABS_Z 0x02 1984-#define ABS_RX 0x03 1985-#define ABS_RY 0x04 1986-#define ABS_RZ 0x05 1987-#define ABS_THROTTLE 0x06 1988-#define ABS_RUDDER 0x07 1989-#define ABS_WHEEL 0x08 1990-#define ABS_GAS 0x09 1991-#define ABS_BRAKE 0x0a 1992-#define ABS_HAT0X 0x10 1993-#define ABS_HAT0Y 0x11 1994-#define ABS_HAT1X 0x12 1995-#define ABS_HAT1Y 0x13 1996-#define ABS_HAT2X 0x14 1997-#define ABS_HAT2Y 0x15 1998-#define ABS_HAT3X 0x16 1999-#define ABS_HAT3Y 0x17 2000-#define ABS_PRESSURE 0x18 2001-#define ABS_DISTANCE 0x19 2002-#define ABS_TILT_X 0x1a 2003-#define ABS_TILT_Y 0x1b 2004-#define ABS_TOOL_WIDTH 0x1c 2005- 2006-#define ABS_VOLUME 0x20 2007- 2008-#define ABS_MISC 0x28 2009- 2010-/* 2011- * 0x2e is reserved and should not be used in input drivers. 2012- * It was used by HID as ABS_MISC+6 and userspace needs to detect if 2013- * the next ABS_* event is correct or is just ABS_MISC + n. 2014- * We define here ABS_RESERVED so userspace can rely on it and detect 2015- * the situation described above. 2016- */ 2017-#define ABS_RESERVED 0x2e 2018- 2019-#define ABS_MT_SLOT 0x2f /* MT slot being modified */ 2020-#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ 2021-#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ 2022-#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ 2023-#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */ 2024-#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */ 2025-#define ABS_MT_POSITION_X 0x35 /* Center X touch position */ 2026-#define ABS_MT_POSITION_Y 0x36 /* Center Y touch position */ 2027-#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device */ 2028-#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob */ 2029-#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 2030-#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 2031-#define ABS_MT_DISTANCE 0x3b /* Contact hover distance */ 2032-#define ABS_MT_TOOL_X 0x3c /* Center X tool position */ 2033-#define ABS_MT_TOOL_Y 0x3d /* Center Y tool position */ 2034- 2035- 2036-#define ABS_MAX 0x3f 2037-#define ABS_CNT (ABS_MAX+1) 2038- 2039-/* 2040- * Switch events 2041- */ 2042- 2043-#define SW_LID 0x00 /* set = lid shut */ 2044-#define SW_TABLET_MODE 0x01 /* set = tablet mode */ 2045-#define SW_HEADPHONE_INSERT 0x02 /* set = inserted */ 2046-#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" 2047- set = radio enabled */ 2048-#define SW_RADIO SW_RFKILL_ALL /* deprecated */ 2049-#define SW_MICROPHONE_INSERT 0x04 /* set = inserted */ 2050-#define SW_DOCK 0x05 /* set = plugged into dock */ 2051-#define SW_LINEOUT_INSERT 0x06 /* set = inserted */ 2052-#define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ 2053-#define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */ 2054-#define SW_CAMERA_LENS_COVER 0x09 /* set = lens covered */ 2055-#define SW_KEYPAD_SLIDE 0x0a /* set = keypad slide out */ 2056-#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ 2057-#define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ 2058-#define SW_LINEIN_INSERT 0x0d /* set = inserted */ 2059-#define SW_MUTE_DEVICE 0x0e /* set = device disabled */ 2060-#define SW_PEN_INSERTED 0x0f /* set = pen inserted */ 2061-#define SW_MACHINE_COVER 0x10 /* set = cover closed */ 2062-#define SW_MAX 0x10 2063-#define SW_CNT (SW_MAX+1) 2064- 2065-/* 2066- * Misc events 2067- */ 2068- 2069-#define MSC_SERIAL 0x00 2070-#define MSC_PULSELED 0x01 2071-#define MSC_GESTURE 0x02 2072-#define MSC_RAW 0x03 2073-#define MSC_SCAN 0x04 2074-#define MSC_TIMESTAMP 0x05 2075-#define MSC_MAX 0x07 2076-#define MSC_CNT (MSC_MAX+1) 2077- 2078-/* 2079- * LEDs 2080- */ 2081- 2082-#define LED_NUML 0x00 2083-#define LED_CAPSL 0x01 2084-#define LED_SCROLLL 0x02 2085-#define LED_COMPOSE 0x03 2086-#define LED_KANA 0x04 2087-#define LED_SLEEP 0x05 2088-#define LED_SUSPEND 0x06 2089-#define LED_MUTE 0x07 2090-#define LED_MISC 0x08 2091-#define LED_MAIL 0x09 2092-#define LED_CHARGING 0x0a 2093-#define LED_MAX 0x0f 2094-#define LED_CNT (LED_MAX+1) 2095- 2096-/* 2097- * Autorepeat values 2098- */ 2099- 2100-#define REP_DELAY 0x00 2101-#define REP_PERIOD 0x01 2102-#define REP_MAX 0x01 2103-#define REP_CNT (REP_MAX+1) 2104- 2105-/* 2106- * Sounds 2107- */ 2108- 2109-#define SND_CLICK 0x00 2110-#define SND_BELL 0x01 2111-#define SND_TONE 0x02 2112-#define SND_MAX 0x07 2113-#define SND_CNT (SND_MAX+1) 2114- 2115-#endif 2116diff -Naur old/src/evdev-fallback.c new/src/evdev-fallback.c 2117--- old/src/evdev-fallback.c 2021-01-01 00:00:00.000000000 +0000 2118+++ new/src/evdev-fallback.c 2021-01-01 00:00:00.000000000 +0000 2119@@ -353,8 +353,11 @@ 2120 struct libinput_device *base = &device->base; 2121 struct libinput_seat *seat = base->seat; 2122 struct device_coords point; 2123+ struct device_coord_rect rect; 2124 struct mt_slot *slot; 2125 int seat_slot; 2126+ struct touch_axis axis; 2127+ int tool_type; 2128 2129 if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) 2130 return false; 2131@@ -377,8 +380,12 @@ 2132 slot->hysteresis_center = point; 2133 evdev_transform_absolute(device, &point); 2134 2135- touch_notify_touch_down(base, time, slot_idx, seat_slot, 2136- &point); 2137+ tool_type = slot->tool_type; 2138+ axis = slot->axis; 2139+ rect = slot->tool_rect; 2140+ evdev_transform_absolute_rect(device, &rect); 2141+ touch_notify_touch_down(base, time, slot_idx, seat_slot, slot->pressure, 2142+ &axis, &point, tool_type, &rect); 2143 2144 return true; 2145 } 2146@@ -391,8 +398,11 @@ 2147 { 2148 struct libinput_device *base = &device->base; 2149 struct device_coords point; 2150+ struct device_coord_rect rect; 2151 struct mt_slot *slot; 2152 int seat_slot; 2153+ struct touch_axis axis; 2154+ int tool_type; 2155 2156 if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) 2157 return false; 2158@@ -400,6 +410,7 @@ 2159 slot = &dispatch->mt.slots[slot_idx]; 2160 seat_slot = slot->seat_slot; 2161 point = slot->point; 2162+ axis = slot->axis; 2163 2164 if (seat_slot == -1) 2165 return false; 2166@@ -408,8 +419,12 @@ 2167 return false; 2168 2169 evdev_transform_absolute(device, &point); 2170- touch_notify_touch_motion(base, time, slot_idx, seat_slot, 2171- &point); 2172+ 2173+ tool_type = slot->tool_type; 2174+ rect = slot->tool_rect; 2175+ evdev_transform_absolute_rect(device, &rect); 2176+ touch_notify_touch_motion(base, time, slot_idx, seat_slot, slot->pressure, 2177+ &axis, &point, tool_type, &rect); 2178 2179 return true; 2180 } 2181@@ -424,6 +439,7 @@ 2182 struct libinput_seat *seat = base->seat; 2183 struct mt_slot *slot; 2184 int seat_slot; 2185+ int tool_type; 2186 2187 if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) 2188 return false; 2189@@ -437,7 +453,9 @@ 2190 2191 seat->slot_map &= ~bit(seat_slot); 2192 2193- touch_notify_touch_up(base, time, slot_idx, seat_slot); 2194+ tool_type = slot->tool_type; 2195+ 2196+ touch_notify_touch_up(base, time, slot_idx, seat_slot, tool_type); 2197 2198 return true; 2199 } 2200@@ -478,7 +496,11 @@ 2201 struct libinput_device *base = &device->base; 2202 struct libinput_seat *seat = base->seat; 2203 struct device_coords point; 2204+ const struct device_coord_rect rect = { 0 }; 2205+ const struct touch_axis axis = { 0 }; 2206 int seat_slot; 2207+ int tool_type; 2208+ int32_t pressure = dispatch->abs.pressure; 2209 2210 if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) 2211 return false; 2212@@ -500,7 +522,9 @@ 2213 point = dispatch->abs.point; 2214 evdev_transform_absolute(device, &point); 2215 2216- touch_notify_touch_down(base, time, -1, seat_slot, &point); 2217+ tool_type = -1; 2218+ 2219+ touch_notify_touch_down(base, time, -1, seat_slot, pressure, &axis, &point, tool_type, &rect); 2220 2221 return true; 2222 } 2223@@ -512,7 +536,11 @@ 2224 { 2225 struct libinput_device *base = &device->base; 2226 struct device_coords point; 2227+ const struct device_coord_rect rect = {0}; 2228+ const struct touch_axis axis = { 0 }; 2229 int seat_slot; 2230+ int tool_type; 2231+ int32_t pressure = dispatch->abs.pressure; 2232 2233 point = dispatch->abs.point; 2234 evdev_transform_absolute(device, &point); 2235@@ -522,7 +550,9 @@ 2236 if (seat_slot == -1) 2237 return false; 2238 2239- touch_notify_touch_motion(base, time, -1, seat_slot, &point); 2240+ tool_type = -1; 2241+ 2242+ touch_notify_touch_motion(base, time, -1, seat_slot, pressure, &axis, &point, tool_type, &rect); 2243 2244 return true; 2245 } 2246@@ -535,6 +565,7 @@ 2247 struct libinput_device *base = &device->base; 2248 struct libinput_seat *seat = base->seat; 2249 int seat_slot; 2250+ int tool_type; 2251 2252 if (!(device->seat_caps & EVDEV_DEVICE_TOUCH)) 2253 return false; 2254@@ -547,7 +578,9 @@ 2255 2256 seat->slot_map &= ~bit(seat_slot); 2257 2258- touch_notify_touch_up(base, time, -1, seat_slot); 2259+ tool_type = -1; 2260+ 2261+ touch_notify_touch_up(base, time, -1, seat_slot, tool_type); 2262 2263 return true; 2264 } 2265@@ -652,6 +685,14 @@ 2266 { 2267 struct mt_slot *slot = &dispatch->mt.slots[dispatch->mt.slot]; 2268 2269+ if (e->code == 0x2a) { 2270+ dispatch->device->sensor_timestamp.seconds = e->value; 2271+ return; 2272+ } 2273+ if (e->code == 0x2b) { 2274+ dispatch->device->sensor_timestamp.microseconds = e->value; 2275+ return; 2276+ } 2277 if (e->code == ABS_MT_SLOT) { 2278 if ((size_t)e->value >= dispatch->mt.slots_len) { 2279 evdev_log_bug_libinput(device, 2280@@ -722,6 +763,42 @@ 2281 break; 2282 } 2283 dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2284+ slot->tool_type = e->value; 2285+ slot->dirty = true; 2286+ break; 2287+ case ABS_MT_PRESSURE: 2288+ slot->pressure = e->value; 2289+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2290+ slot->dirty = true; 2291+ break; 2292+ case ABS_MT_TOUCH_MAJOR: 2293+ slot->axis.major = e->value; 2294+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2295+ slot->dirty = true; 2296+ break; 2297+ case ABS_MT_TOUCH_MINOR: 2298+ slot->axis.minor = e->value; 2299+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2300+ slot->dirty = true; 2301+ break; 2302+ case ABS_MT_WIDTH_MAJOR: 2303+ slot->tool_rect.w = e->value; 2304+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2305+ slot->dirty = true; 2306+ break; 2307+ case ABS_MT_WIDTH_MINOR: 2308+ slot->tool_rect.h = e->value; 2309+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2310+ slot->dirty = true; 2311+ break; 2312+ case ABS_MT_TOOL_X: 2313+ slot->tool_rect.x = e->value; 2314+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2315+ slot->dirty = true; 2316+ break; 2317+ case ABS_MT_TOOL_Y: 2318+ slot->tool_rect.y = e->value; 2319+ dispatch->pending_event |= EVDEV_ABSOLUTE_MT; 2320 slot->dirty = true; 2321 break; 2322 } 2323@@ -743,6 +820,10 @@ 2324 dispatch->abs.point.y = e->value; 2325 dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION; 2326 break; 2327+ case ABS_PRESSURE: 2328+ dispatch->abs.pressure = e->value; 2329+ dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION; 2330+ break; 2331 } 2332 } 2333 2334@@ -1673,6 +1754,7 @@ 2335 2336 for (slot = 0; slot < num_slots; ++slot) { 2337 slots[slot].seat_slot = -1; 2338+ slots[slot].tool_type = -1; 2339 2340 if (evdev_need_mtdev(device)) 2341 continue; 2342@@ -1848,3 +1930,11 @@ 2343 2344 return &dispatch->base; 2345 } 2346+ 2347+bool 2348+evdev_device_touch_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType) 2349+{ 2350+ struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch); 2351+ 2352+ return hw_is_key_down(dispatch, btnToolType); 2353+} 2354diff -Naur old/src/evdev-fallback.h new/src/evdev-fallback.h 2355--- old/src/evdev-fallback.h 2021-01-01 00:00:00.000000000 +0000 2356+++ new/src/evdev-fallback.h 2021-01-01 00:00:00.000000000 +0000 2357@@ -66,6 +66,10 @@ 2358 struct device_coords point; 2359 struct device_coords hysteresis_center; 2360 enum palm_state palm_state; 2361+ struct device_coord_rect tool_rect; 2362+ int32_t pressure; 2363+ struct touch_axis axis; 2364+ int32_t tool_type; 2365 }; 2366 2367 struct fallback_dispatch { 2368@@ -84,6 +88,7 @@ 2369 struct { 2370 struct device_coords point; 2371 int32_t seat_slot; 2372+ int32_t pressure; 2373 } abs; 2374 2375 struct { 2376@@ -176,6 +181,7 @@ 2377 static inline enum key_type 2378 get_key_type(uint16_t code) 2379 { 2380+ const uint16_t KEY_ENDCALL = 0x2e8; 2381 switch (code) { 2382 case BTN_TOOL_PEN: 2383 case BTN_TOOL_RUBBER: 2384@@ -205,6 +211,8 @@ 2385 return KEY_TYPE_KEY; 2386 if (code >= BTN_TRIGGER_HAPPY && code <= BTN_TRIGGER_HAPPY40) 2387 return KEY_TYPE_BUTTON; 2388+ if (code == KEY_ENDCALL) 2389+ return KEY_TYPE_KEY; 2390 return KEY_TYPE_NONE; 2391 } 2392 2393diff -Naur old/src/evdev-joystick.c new/src/evdev-joystick.c 2394--- old/src/evdev-joystick.c 1970-01-01 00:00:00.000000000 +0000 2395+++ new/src/evdev-joystick.c 2021-01-01 00:00:00.000000000 +0000 2396@@ -0,0 +1,591 @@ 2397+/* 2398+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2399+ * Licensed under the Apache License, Version 2.0 (the "License"); 2400+ * you may not use this file except in compliance with the License. 2401+ * You may obtain a copy of the License at 2402+ * 2403+ * http://www.apache.org/licenses/LICENSE-2.0 2404+ * 2405+ * Unless required by applicable law or agreed to in writing, software 2406+ * distributed under the License is distributed on an "AS IS" BASIS, 2407+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2408+ * See the License for the specific language governing permissions and 2409+ * limitations under the License. 2410+ */ 2411+ 2412+#include <stdbool.h> 2413+#include <string.h> 2414+ 2415+#include "config.h" 2416+#include "libinput-version.h" 2417+#include "evdev-joystick.h" 2418+#include "input-event-codes.h" 2419+#include "libinput.h" 2420+#include "libinput-util.h" 2421+ 2422+static inline struct 2423+joystick_dispatch* get_joystick_dispatch(struct evdev_dispatch* dispatch) 2424+{ 2425+ if (dispatch == NULL) { 2426+ return NULL; 2427+ } 2428+ evdev_verify_dispatch_type(dispatch, DISPATCH_JOYSTICK); 2429+ 2430+ struct joystick_dispatch* joystick_dispatch = NULL; 2431+ joystick_dispatch = container_of(dispatch, struct joystick_dispatch, base); 2432+ 2433+ return joystick_dispatch; 2434+} 2435+ 2436+static int 2437+update_seat_joystick_button_count(struct libinput_seat* seat, int32_t key, uint32_t *seat_count, enum libinput_button_state state) 2438+{ 2439+ if (seat == NULL || seat_count == NULL || key < SYN_REPORT || key > KEY_MAX) { 2440+ return false; 2441+ } 2442+ 2443+ switch (state) { 2444+ case LIBINPUT_BUTTON_STATE_PRESSED: 2445+ { 2446+ *(seat_count) = ++seat->button_count[key]; 2447+ break; 2448+ } 2449+ case LIBINPUT_BUTTON_STATE_RELEASED: 2450+ { 2451+ if (seat->button_count[key] == 0) 2452+ { 2453+ *(seat_count) = seat->button_count[key]; 2454+ } 2455+ else 2456+ { 2457+ *(seat_count) = --seat->button_count[key]; 2458+ } 2459+ break; 2460+ } 2461+ default: 2462+ { 2463+ *(seat_count) = 0; 2464+ break; 2465+ } 2466+ } 2467+ return true; 2468+} 2469+ 2470+static void 2471+joystick_notify_axis(struct evdev_device* device, uint64_t time) 2472+{ 2473+ if (device == NULL) { 2474+ return; 2475+ } 2476+ 2477+ struct joystick_dispatch *joystick_dispatch = get_joystick_dispatch(device->dispatch); 2478+ if (joystick_dispatch == NULL) { 2479+ libinput_log_printf("joystick_dispatch is NULL.\n"); 2480+ return; 2481+ } 2482+ 2483+ struct libinput_event_joystick_axis* joystick_axis_event = zalloc(sizeof * joystick_axis_event); 2484+ if (joystick_axis_event == NULL) { 2485+ libinput_log_printf("pJoystickEvent is NULL.\n"); 2486+ return; 2487+ } 2488+ 2489+ *joystick_axis_event = (struct libinput_event_joystick_axis) { 2490+ .base.type = LIBINPUT_EVENT_POINTER_AXIS, 2491+ .base.device = &device->base, 2492+ .type = EV_ABS, 2493+ .time = time, 2494+ .axis_value_mask = joystick_dispatch->axis_value_mask, 2495+ .abs_throttle = joystick_dispatch->axis_abs_infos.abs_throttle, 2496+ .abs_hat0x = joystick_dispatch->axis_abs_infos.abs_hat0x, 2497+ .abs_hat0y = joystick_dispatch->axis_abs_infos.abs_hat0y, 2498+ .abs_x = joystick_dispatch->axis_abs_infos.abs_x, 2499+ .abs_y = joystick_dispatch->axis_abs_infos.abs_y, 2500+ .abs_z = joystick_dispatch->axis_abs_infos.abs_z, 2501+ .abs_rx = joystick_dispatch->axis_abs_infos.abs_rx, 2502+ .abs_ry = joystick_dispatch->axis_abs_infos.abs_ry, 2503+ .abs_rz = joystick_dispatch->axis_abs_infos.abs_rz, 2504+ }; 2505+ 2506+ struct libinput_event_listener* listener = NULL; 2507+ list_for_each_safe(listener, &device->base.event_listeners, link) { 2508+ listener->notify_func(time, &joystick_axis_event->base, listener->notify_func_data); 2509+ } 2510+ 2511+ libinput_post_handle_event(device->base.seat->libinput, &joystick_axis_event->base); 2512+} 2513+ 2514+static void 2515+joystick_notify_key_event(struct evdev_device* device, struct input_event* event, uint64_t time) 2516+{ 2517+ if (device == NULL || event == NULL) { 2518+ return; 2519+ } 2520+ 2521+ struct libinput_event_joystick_button* button_event = {0}; 2522+ uint32_t seat_count = 0; 2523+ 2524+ int ret = update_seat_joystick_button_count(device->base.seat, event->code, &seat_count, event->value); 2525+ if (ret == 0) { 2526+ return; 2527+ } 2528+ 2529+ button_event = zalloc(sizeof * button_event); 2530+ if (button_event == NULL) { 2531+ return; 2532+ } 2533+ 2534+ *button_event = (struct libinput_event_joystick_button) { 2535+ .base.type = LIBINPUT_EVENT_JOYSTICK_BUTTON, 2536+ .base.device = &device->base, 2537+ .time = time, 2538+ .type = event->type, 2539+ .key = event->code, 2540+ .value = event->value, 2541+ .seat_key_count = seat_count, 2542+ .state = event->value, 2543+ }; 2544+ 2545+ struct libinput_event_listener* listener = NULL; 2546+ list_for_each_safe(listener, &device->base.event_listeners, link) 2547+ { 2548+ listener->notify_func(time, &button_event->base, listener->notify_func_data); 2549+ } 2550+ 2551+ libinput_post_handle_event(device->base.seat->libinput, &button_event->base); 2552+} 2553+ 2554+static float 2555+abs_value_standardize(int32_t value, int32_t minimum, int32_t maximum, float standard_min, float standard_max) 2556+{ 2557+ return standard_min + ((float)value - (float)minimum) * ((float)(standard_max - standard_min)) / ((float)(maximum - minimum)); 2558+} 2559+ 2560+static float 2561+get_joystick_abs_standard_value(struct libinput_event_joystick_axis_abs_info *absinfo) 2562+{ 2563+ const int32_t value = absinfo->value; 2564+ const int32_t minimum = absinfo->minimum; 2565+ const int32_t maximum = absinfo->maximum; 2566+ if (minimum >= maximum) { 2567+ libinput_log_printf("joystick abs: minimum(%u) >= maximum(%u).\n", minimum, maximum); 2568+ return 0.f; 2569+ } else if (value < minimum || value > maximum) { 2570+ libinput_log_printf("joystick abs: value(%d) not between minimum(%u) and maximum(%u).\n", value, minimum, maximum); 2571+ return 0.f; 2572+ } 2573+ 2574+ const int32_t code = absinfo->code; 2575+ switch (code) { 2576+ case ABS_THROTTLE: 2577+ { 2578+ return abs_value_standardize(value, minimum, maximum, 0, 1.0); 2579+ } 2580+ case ABS_X: 2581+ case ABS_Y: 2582+ case ABS_Z: 2583+ case ABS_RX: 2584+ case ABS_RY: 2585+ case ABS_RZ: 2586+ { 2587+ return abs_value_standardize(value, minimum, maximum, -1.0, 1.0); 2588+ } 2589+ case ABS_HAT0X: 2590+ case ABS_HAT0Y: 2591+ { 2592+ return (float)value; 2593+ } 2594+ default: 2595+ return (float)value; 2596+ } 2597+} 2598+ 2599+static void joystick_set_axis_value_mask(struct joystick_dispatch *joystick_dispatch, enum libinput_joystick_axis_source axis) 2600+{ 2601+ joystick_dispatch->axis_value_mask |= (uint32_t)axis; 2602+} 2603+ 2604+static void joystick_reset_axis_value_mask(struct joystick_dispatch *joystick_dispatch) 2605+{ 2606+ joystick_dispatch->axis_value_mask = 0; 2607+} 2608+ 2609+static bool joystick_is_axis_value_mask(struct joystick_dispatch *joystick_dispatch) 2610+{ 2611+ return (joystick_dispatch->axis_value_mask != 0); 2612+} 2613+ 2614+static void joystick_get_one_abs_info(struct joystick_dispatch *joystick_dispatch, struct evdev_device *device, struct input_event *event, 2615+ const uint32_t code) 2616+{ 2617+ struct libinput_event_joystick_axis_abs_info *absinfo = NULL; 2618+ switch (code) { 2619+ case ABS_THROTTLE: 2620+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE); 2621+ absinfo = &joystick_dispatch->axis_abs_infos.abs_throttle; 2622+ break; 2623+ case ABS_HAT0X: 2624+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X); 2625+ absinfo = &joystick_dispatch->axis_abs_infos.abs_hat0x; 2626+ break; 2627+ case ABS_HAT0Y: 2628+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y); 2629+ absinfo = &joystick_dispatch->axis_abs_infos.abs_hat0y; 2630+ break; 2631+ case ABS_X: 2632+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X); 2633+ absinfo = &joystick_dispatch->axis_abs_infos.abs_x; 2634+ break; 2635+ case ABS_Y: 2636+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y); 2637+ absinfo = &joystick_dispatch->axis_abs_infos.abs_y; 2638+ break; 2639+ case ABS_Z: 2640+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z); 2641+ absinfo = &joystick_dispatch->axis_abs_infos.abs_z; 2642+ break; 2643+ case ABS_RX: 2644+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX); 2645+ absinfo = &joystick_dispatch->axis_abs_infos.abs_rx; 2646+ break; 2647+ case ABS_RY: 2648+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY); 2649+ absinfo = &joystick_dispatch->axis_abs_infos.abs_ry; 2650+ break; 2651+ case ABS_RZ: 2652+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ); 2653+ absinfo = &joystick_dispatch->axis_abs_infos.abs_rz; 2654+ break; 2655+ case ABS_GAS: 2656+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS); 2657+ absinfo = &joystick_dispatch->axis_abs_infos.abs_gas; 2658+ break; 2659+ case ABS_BRAKE: 2660+ joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE); 2661+ absinfo = &joystick_dispatch->axis_abs_infos.abs_brake; 2662+ break; 2663+ default: 2664+ break; 2665+ } 2666+ 2667+ if (absinfo == NULL) { 2668+ libinput_log_printf("unsupported joystick abs event: device_name:%s code:%d value:%d.\n", 2669+ device->devname, code, event->value); 2670+ return; 2671+ } 2672+ 2673+ struct libevdev *evdev = device->evdev; 2674+ evdev_device_check_abs_axis_range(device, event->code, event->value); 2675+ const struct input_absinfo *absinfo_raw = libevdev_get_abs_info(evdev, event->code); 2676+ absinfo->code = event->code; 2677+ absinfo->value = event->value; 2678+ absinfo->minimum = absinfo_raw->minimum; 2679+ absinfo->maximum = absinfo_raw->maximum; 2680+ absinfo->fuzz = absinfo_raw->fuzz; 2681+ absinfo->flat = absinfo_raw->flat; 2682+ absinfo->resolution = absinfo_raw->resolution; 2683+ absinfo->standardValue = get_joystick_abs_standard_value(absinfo); 2684+} 2685+ 2686+static void 2687+joystick_notify_absolute_event(struct joystick_dispatch* pJoystick, 2688+ struct evdev_device* device, struct input_event* event, uint64_t time) 2689+{ 2690+ if (pJoystick == NULL || device == NULL || event == NULL) { 2691+ return; 2692+ } 2693+ 2694+ joystick_get_one_abs_info(pJoystick, device, event, event->code); 2695+} 2696+ 2697+static void 2698+joystick_flush(struct joystick_dispatch* joystick_dispatch, struct evdev_device* device, uint64_t time) 2699+{ 2700+ if (joystick_dispatch == NULL || device == NULL) { 2701+ return; 2702+ } 2703+ 2704+ if (joystick_dispatch->axis_value_mask != 0) { 2705+ joysticks_notify_axis(&device->base, time, joystick_dispatch->axis_value_mask, 2706+ &joystick_dispatch->axis_abs_infos); 2707+ joystick_reset_axis_value_mask(joystick_dispatch); 2708+ } 2709+} 2710+ 2711+static void 2712+joystick_process(struct evdev_dispatch* dispatch, struct evdev_device* device, 2713+ struct input_event* event, uint64_t time) 2714+{ 2715+ if (dispatch == NULL || device == NULL || event == NULL) { 2716+ return; 2717+ } 2718+ 2719+ struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(dispatch); 2720+ if (joystick_dispatch == NULL) { 2721+ return; 2722+ } 2723+ 2724+ switch (event->type) { 2725+ case EV_ABS: { 2726+ joystick_notify_absolute_event(joystick_dispatch, device, event, time); 2727+ } 2728+ break; 2729+ case EV_KEY: { 2730+ joystick_notify_key_event(device, event, time); 2731+ } 2732+ break; 2733+ case EV_SYN: { 2734+ joystick_flush(joystick_dispatch, device, time); 2735+ } 2736+ break; 2737+ case EV_MSC: 2738+ /* ignore do not process */ 2739+ break; 2740+ case EV_REL: 2741+ case EV_SW: 2742+ case EV_LED: 2743+ case EV_SND: 2744+ case EV_REP: 2745+ case EV_FF: 2746+ case EV_PWR: 2747+ case EV_FF_STATUS: 2748+ case EV_MAX: 2749+ case EV_CNT: 2750+ default: 2751+ libinput_log_printf("unsupported joystick event type: %d, devname: %s.\n", event->type, device->devname); 2752+ break; 2753+ } 2754+} 2755+ 2756+static void joystick_suspend(struct evdev_dispatch* dispatch, struct evdev_device* device) 2757+{ 2758+ if (dispatch == NULL || device == NULL) { 2759+ return; 2760+ } 2761+ struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(dispatch); 2762+ if (joystick_dispatch == NULL) { 2763+ return; 2764+ } 2765+ joystick_flush(joystick_dispatch, device, 0); 2766+} 2767+ 2768+static void 2769+joystick_destroy(struct evdev_dispatch* dispatch) 2770+{ 2771+ if (dispatch == NULL) { 2772+ return; 2773+ } 2774+ struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(dispatch); 2775+ if (dispatch == NULL) { 2776+ return; 2777+ } 2778+ 2779+ free(joystick_dispatch); 2780+} 2781+ 2782+static void 2783+joystick_device_added(struct evdev_device* device, 2784+ struct evdev_device* added_device) 2785+{ 2786+ if (device == NULL || added_device == NULL) { 2787+ return; 2788+ } 2789+ struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(device->dispatch); 2790+ if (joystick_dispatch == NULL) { 2791+ return; 2792+ } 2793+ 2794+ bool is_joystick = false; 2795+ if (libinput_device_get_device_group(&device->base) != 2796+ libinput_device_get_device_group(&added_device->base)) { 2797+ return; 2798+ } 2799+ is_joystick = evdev_device_has_capability(added_device, 2800+ LIBINPUT_DEVICE_CAP_JOYSTICK); 2801+ 2802+ if (is_joystick) { 2803+ evdev_log_debug(device, 2804+ "joystick: activated for %s<->%s\n", 2805+ device->devname, 2806+ added_device->devname); 2807+ joystick_dispatch->device = added_device; 2808+ } 2809+} 2810+ 2811+static void 2812+joystick_device_removed(struct evdev_device* device, 2813+ struct evdev_device* removed_device) 2814+{ 2815+ if (device == NULL || removed_device == NULL) { 2816+ return; 2817+ } 2818+ struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(device->dispatch); 2819+ if (joystick_dispatch == NULL) { 2820+ return; 2821+ } 2822+ 2823+ if (joystick_dispatch->device == removed_device) { 2824+ joystick_dispatch->device = NULL; 2825+ } 2826+} 2827+ 2828+static struct evdev_dispatch_interface joystick_interface = { 2829+ .process = joystick_process, 2830+ .suspend = joystick_suspend, 2831+ .remove = NULL, 2832+ .destroy = joystick_destroy, 2833+ .device_added = joystick_device_added, 2834+ .device_removed = joystick_device_removed, 2835+ .device_suspended = NULL, 2836+ .device_resumed = NULL, 2837+ .post_added = NULL, 2838+ .touch_arbitration_toggle = NULL, 2839+ .touch_arbitration_update_rect = NULL, 2840+ .get_switch_state = NULL, 2841+}; 2842+ 2843+static enum libinput_config_status 2844+joystick_sendevents_set_mode(struct libinput_device* device, 2845+ enum libinput_config_send_events_mode mode) 2846+{ 2847+ if (device == NULL) { 2848+ return LIBINPUT_CONFIG_STATUS_INVALID; 2849+ } 2850+ 2851+ struct evdev_device* ev_device = evdev_device(device); 2852+ struct joystick_dispatch* joystick_dispatch = (struct joystick_dispatch*)ev_device->dispatch; 2853+ 2854+ if (ev_device == NULL || joystick_dispatch == NULL) { 2855+ return LIBINPUT_CONFIG_STATUS_INVALID; 2856+ } 2857+ 2858+ if (mode == joystick_dispatch->sendevents.current_mode) { 2859+ return LIBINPUT_CONFIG_STATUS_SUCCESS; 2860+ } 2861+ 2862+ switch (mode) { 2863+ case LIBINPUT_CONFIG_SEND_EVENTS_ENABLED: 2864+ break; 2865+ case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED: 2866+ joystick_suspend(ev_device->dispatch, ev_device); 2867+ break; 2868+ default: 2869+ return LIBINPUT_CONFIG_STATUS_UNSUPPORTED; 2870+ } 2871+ 2872+ joystick_dispatch->sendevents.current_mode = mode; 2873+ 2874+ return LIBINPUT_CONFIG_STATUS_SUCCESS; 2875+} 2876+ 2877+static uint32_t 2878+joystick_sendevents_get_modes(struct libinput_device* device) 2879+{ 2880+ return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; 2881+} 2882+ 2883+static enum libinput_config_send_events_mode 2884+joystick_sendevents_get_mode(struct libinput_device* device) 2885+{ 2886+ if (device == NULL) { 2887+ return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; 2888+ } 2889+ 2890+ struct evdev_device* ev_device = evdev_device(device); 2891+ struct joystick_dispatch* pDispatch = (struct joystick_dispatch*)ev_device->dispatch; 2892+ 2893+ if (ev_device == NULL || pDispatch == NULL) { 2894+ return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; 2895+ } 2896+ 2897+ return pDispatch->sendevents.current_mode; 2898+} 2899+ 2900+static enum libinput_config_send_events_mode 2901+joystick_sendevents_get_default_mode(struct libinput_device* device) 2902+{ 2903+ return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; 2904+} 2905+ 2906+#ifdef _DEBUG 2907+void printf_joystick_absinfo(const char *abs_name, struct libinput_event_joystick_axis_abs_info *absinfo) 2908+{ 2909+ printf("%s: code: %d, value: %d, minimum: %d, maximum: %d, fuzz: %d, flat: %d, resolution: %d, standardValue: %f\n", 2910+ abs_name, 2911+ absinfo->code, 2912+ absinfo->value, 2913+ absinfo->minimum, 2914+ absinfo->maximum, 2915+ absinfo->fuzz, 2916+ absinfo->flat, 2917+ absinfo->resolution, 2918+ absinfo->standardValue 2919+ ); 2920+} 2921+ 2922+void print_libinput_event_joystick_axis(struct libinput_event_joystick_axis *p) 2923+{ 2924+ printf("JOYSTICK:\n" 2925+ "type: %d, device: %p, type: %d, time: 0x%x\n", 2926+ p->base.type, 2927+ p->base.device, 2928+ p->type, 2929+ p->time); 2930+ printf_joystick_absinfo("abs_throttle", &p->abs_throttle); 2931+ printf_joystick_absinfo("abs_hat0x", &p->abs_hat0x); 2932+ printf_joystick_absinfo("abs_hat0y", &p->abs_hat0y); 2933+ printf_joystick_absinfo("abs_x", &p->abs_x); 2934+ printf_joystick_absinfo("abs_y", &p->abs_y); 2935+ printf_joystick_absinfo("abs_z", &p->abs_z); 2936+ printf_joystick_absinfo("abs_rx", &p->abs_rx); 2937+ printf_joystick_absinfo("abs_ry", &p->abs_ry); 2938+ printf_joystick_absinfo("abs_rz", &p->abs_rz); 2939+} 2940+#endif // _DEBUG 2941+ 2942+/** 2943+ * @brief 初始化joystick_dispatch 2944+ * @param joystick 2945+ * @param device 2946+ * @return bool true - 成功, false - 失败 2947+*/ 2948+bool 2949+joystick_init(struct joystick_dispatch* pJoystick, struct evdev_device* device) 2950+{ 2951+ if (pJoystick == NULL || device == NULL) { 2952+ return false; 2953+ } 2954+ 2955+ pJoystick->base.dispatch_type = DISPATCH_JOYSTICK; 2956+ pJoystick->base.interface = &joystick_interface; 2957+ pJoystick->device = device; 2958+ 2959+ return true; 2960+} 2961+ 2962+struct evdev_dispatch* 2963+evdev_joystick_create(struct evdev_device* device) 2964+{ 2965+ if (device == NULL) { 2966+ return NULL; 2967+ } 2968+ 2969+ struct joystick_dispatch* joystick = {0}; 2970+ joystick = zalloc(sizeof * joystick); 2971+ 2972+ if (joystick_init(joystick, device) != true) { 2973+ joystick_destroy(&joystick->base); 2974+ joystick = NULL; 2975+ return NULL; 2976+ } 2977+ 2978+ device->base.config.sendevents = &joystick->sendevents.config; 2979+ joystick->sendevents.current_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; 2980+ joystick->sendevents.config.get_modes = joystick_sendevents_get_modes; 2981+ joystick->sendevents.config.set_mode = joystick_sendevents_set_mode; 2982+ joystick->sendevents.config.get_mode = joystick_sendevents_get_mode; 2983+ joystick->sendevents.config.get_default_mode = joystick_sendevents_get_default_mode; 2984+ 2985+ return &joystick->base; 2986+} 2987+ 2988diff -Naur old/src/evdev-joystick.h new/src/evdev-joystick.h 2989--- old/src/evdev-joystick.h 1970-01-01 00:00:00.000000000 +0000 2990+++ new/src/evdev-joystick.h 2021-01-01 00:00:00.000000000 +0000 2991@@ -0,0 +1,71 @@ 2992+/* 2993+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 2994+ * Licensed under the Apache License, Version 2.0 (the "License"); 2995+ * you may not use this file except in compliance with the License. 2996+ * You may obtain a copy of the License at 2997+ * 2998+ * http://www.apache.org/licenses/LICENSE-2.0 2999+ * 3000+ * Unless required by applicable law or agreed to in writing, software 3001+ * distributed under the License is distributed on an "AS IS" BASIS, 3002+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3003+ * See the License for the specific language governing permissions and 3004+ * limitations under the License. 3005+ */ 3006+#ifndef LIBINPUT_EVDEV_JOYSTICK_H 3007+#define LIBINPUT_EVDEV_JOYSTICK_H 3008+ 3009+#include "evdev.h" 3010+#include "libinput-private.h" 3011+ 3012+struct joystick_dispatch { 3013+ struct evdev_dispatch base; 3014+ struct evdev_device* device; 3015+ uint32_t axis_value_mask; 3016+ struct joystick_axis_abs_infos axis_abs_infos; 3017+ struct { 3018+ struct libinput_device_config_send_events config; 3019+ enum libinput_config_send_events_mode current_mode; 3020+ } sendevents; 3021+}; 3022+ 3023+struct libinput_event_joystick_button { 3024+ struct libinput_event base; 3025+ uint32_t type; 3026+ uint64_t time; 3027+ uint32_t key; 3028+ uint32_t seat_key_count; 3029+ enum libinput_button_state state; 3030+ int value; 3031+}; 3032+ 3033+struct libinput_event_joystick_axis { 3034+ struct libinput_event base; 3035+ uint32_t type; 3036+ uint64_t time; 3037+ uint32_t axis_value_mask; 3038+ struct libinput_event_joystick_axis_abs_info abs_throttle; 3039+ struct libinput_event_joystick_axis_abs_info abs_hat0x; 3040+ struct libinput_event_joystick_axis_abs_info abs_hat0y; 3041+ struct libinput_event_joystick_axis_abs_info abs_x; 3042+ struct libinput_event_joystick_axis_abs_info abs_y; 3043+ struct libinput_event_joystick_axis_abs_info abs_z; 3044+ struct libinput_event_joystick_axis_abs_info abs_rx; 3045+ struct libinput_event_joystick_axis_abs_info abs_ry; 3046+ struct libinput_event_joystick_axis_abs_info abs_rz; 3047+ struct libinput_event_joystick_axis_abs_info abs_gas; 3048+ struct libinput_event_joystick_axis_abs_info abs_brake; 3049+}; 3050+ 3051+#ifdef _DEBUG 3052+void print_libinput_event_joystick_axis(struct libinput_event_joystick_axis* p); 3053+#endif // _DEBUG 3054+ 3055+/** 3056+ * @brief 创建evdev_dispatch结构体 3057+ * @param device 3058+ * @return struct evdev_dispatch* 3059+*/ 3060+struct evdev_dispatch* evdev_joystick_create(struct evdev_device* device); 3061+ 3062+#endif 3063diff -Naur old/src/evdev-mt-touchpad-buttons.c new/src/evdev-mt-touchpad-buttons.c 3064--- old/src/evdev-mt-touchpad-buttons.c 2021-01-01 00:00:00.000000000 +0000 3065+++ new/src/evdev-mt-touchpad-buttons.c 2021-01-01 00:00:00.000000000 +0000 3066@@ -1202,10 +1202,11 @@ 3067 return 0; 3068 } 3069 3070- evdev_pointer_notify_button(tp->device, time, button, state); 3071+ evdev_pointer_notify_button_touchpad(tp->device, time, button, state); 3072 return 1; 3073 } 3074 3075+#define BTN_RIGHT_MENUE 0x118 3076 static int 3077 tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time) 3078 { 3079@@ -1268,7 +1269,7 @@ 3080 } else if (area & RIGHT) { 3081 button = BTN_RIGHT; 3082 } else if (area & LEFT) { 3083- button = BTN_LEFT; 3084+ button = BTN_RIGHT_MENUE; 3085 } else { /* main or no area (for clickfinger) is always BTN_LEFT */ 3086 button = BTN_LEFT; 3087 want_left_handed = false; 3088diff -Naur old/src/evdev-mt-touchpad-gestures.c new/src/evdev-mt-touchpad-gestures.c 3089--- old/src/evdev-mt-touchpad-gestures.c 2021-01-01 00:00:00.000000000 +0000 3090+++ new/src/evdev-mt-touchpad-gestures.c 2021-01-01 00:00:00.000000000 +0000 3091@@ -124,6 +124,37 @@ 3092 } 3093 3094 static void 3095+tp_get_raw_touches(struct tp_dispatch *tp, struct sloted_coords_info *raw_touches) 3096+{ 3097+ struct tp_touch *t; 3098+ unsigned int i; 3099+ raw_touches->active_count = 0; 3100+ 3101+ if (tp->num_slots > MAX_SOLTED_COORDS_NUM) { 3102+ evdev_log_bug_libinput(tp->device, 3103+ "in %s, num_slots: %d, more than %d\n", 3104+ __func__, tp->num_slots, MAX_SOLTED_COORDS_NUM); 3105+ } 3106+ const unsigned int num_slots = (tp->num_slots > MAX_SOLTED_COORDS_NUM) ? MAX_SOLTED_COORDS_NUM : tp->num_slots; 3107+ 3108+ for (i = 0; i < num_slots; i++) { 3109+ t = &tp->touches[i]; 3110+ 3111+ if (!tp_touch_active_for_gesture(tp, t)) 3112+ continue; 3113+ 3114+ if (t->dirty) { 3115+ struct device_coords d; 3116+ d = tp_get_delta(t); 3117+ raw_touches->coords[i].x = d.x; 3118+ raw_touches->coords[i].y = d.y; 3119+ } 3120+ raw_touches->coords[i].is_active = true; 3121+ raw_touches->active_count++; 3122+ } 3123+} 3124+ 3125+static void 3126 tp_gesture_init_scroll(struct tp_dispatch *tp) 3127 { 3128 struct phys_coords zero = {0.0, 0.0}; 3129@@ -180,7 +211,7 @@ 3130 gesture_notify_swipe(&tp->device->base, time, 3131 LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 3132 tp->gesture.finger_count, 3133- &zero, &zero); 3134+ &zero, &zero, NULL); 3135 break; 3136 case GESTURE_STATE_POINTER_MOTION: 3137 break; 3138@@ -233,7 +264,7 @@ 3139 struct device_float_coords unaccel; 3140 3141 unaccel = tp_scale_to_xaxis(tp, raw); 3142- pointer_notify_motion(&tp->device->base, 3143+ touchpad_pointer_notify_motion(&tp->device->base, 3144 time, 3145 &delta, 3146 &unaccel); 3147@@ -1187,14 +1218,150 @@ 3148 &delta); 3149 } 3150 3151+static double 3152+calculate_cosine_similarity(struct tp_dispatch *tp, struct device_coords *delta1, struct device_coords *delta2) 3153+{ 3154+ 3155+ double dx1 = delta1->x; 3156+ double dy1 = delta1->y; 3157+ double dx2 = delta2->x; 3158+ double dy2 = delta2->y; 3159+ 3160+ double dist1 = sqrt(dx1 * dx1 + dy1 * dy1); 3161+ double dist2 = sqrt(dx2 * dx2 + dy2 * dy2); 3162+ 3163+ if (dist1 < 1 && dist2 < 1) { 3164+ return 0.0; 3165+ } 3166+ double ret = (dx1 * dx2 + dy1 * dy2) / (dist1 * dist2); 3167+ 3168+ return ret; 3169+} 3170+ 3171+static double 3172+calculate_finger_speed(struct tp_dispatch *tp, struct device_coords *curr_coord, struct device_coords *pre_coord) 3173+{ 3174+ int delta_x = curr_coord->x - pre_coord->x; 3175+ int delta_y = curr_coord->y - pre_coord->y; 3176+ 3177+ return sqrt(delta_x * delta_x + delta_y * delta_y); 3178+} 3179+ 3180+struct gesture_device_coords { 3181+ struct device_coords coords[5]; 3182+ int coords_len; 3183+}; 3184+ 3185+#define FINGER_COUNT_MAX 5 3186+static struct gesture_device_coords * 3187+get_gesture_device_coords(void) 3188+{ 3189+ static struct gesture_device_coords gesture_coords = { 3190+ {{0, 0}, 3191+ {0, 0}, 3192+ {0, 0}, 3193+ {0, 0}, 3194+ {0, 0},}, 3195+ FINGER_COUNT_MAX 3196+ }; 3197+ 3198+ return &gesture_coords; 3199+} 3200+ 3201+static void 3202+updata_gesture_device_coords(struct device_coords *coords, int coords_len) 3203+{ 3204+ struct gesture_device_coords * gesture_coords = get_gesture_device_coords(); 3205+ memcpy(gesture_coords->coords, coords, coords_len * sizeof(struct device_coords)); 3206+ gesture_coords->coords_len = coords_len; 3207+} 3208+ 3209+static void 3210+reset_gesture_device_coords(void) 3211+{ 3212+ struct gesture_device_coords * gesture_coords = get_gesture_device_coords(); 3213+ memset(gesture_coords->coords, 0, FINGER_COUNT_MAX * sizeof(struct device_coords)); 3214+ gesture_coords->coords_len = FINGER_COUNT_MAX; 3215+} 3216+ 3217+#define FOUR_FINGER_SIMILAR_CNT 6 3218+#define THREE_FINGER_SIMILAR_CNT 3 3219+static bool 3220+calculate_swipe_cosine_similarity(struct tp_dispatch *tp, struct device_coords *coords, int coordsLen) 3221+{ 3222+ // 3 or 4 finger 3223+ double similaritys[FOUR_FINGER_SIMILAR_CNT] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; 3224+ if (coordsLen == 3 || coordsLen == 4) { 3225+ uint idx = 0; 3226+ for (int i = 0; i < coordsLen; i++) { 3227+ for (int j = i + 1; j < coordsLen; j++) { 3228+ similaritys[idx] = calculate_cosine_similarity(tp, &coords[i], &coords[j]); 3229+ idx++; 3230+ } 3231+ } 3232+ } else { 3233+ return 0.0; 3234+ } 3235+ 3236+ int similarity_count = 0; 3237+ double sum = 0.0; 3238+ double ave = 0.0; 3239+ double variance = 0.0; 3240+ 3241+ similarity_count = (coordsLen == 4) ? FOUR_FINGER_SIMILAR_CNT : THREE_FINGER_SIMILAR_CNT; 3242+ for (int i = 0; i < similarity_count; i++) { 3243+ sum += similaritys[i]; 3244+ } 3245+ ave = sum / similarity_count; 3246+ 3247+ // Calculate variance 3248+ for (int i = 0; i < similarity_count; i++) { 3249+ variance += pow(similaritys[i] - ave, 2) / similarity_count; 3250+ } 3251+ 3252+ // variance <= 0.001 are the same direction 3253+ return variance < 0.001 ? true : false; 3254+} 3255+ 3256+static void 3257+tp_gesture_handle_state_swipe_private(struct tp_dispatch *tp, uint64_t time) 3258+{ 3259+ struct device_float_coords raw; 3260+ struct normalized_coords delta, unaccel; 3261+ 3262+ raw = tp_get_average_touches_delta(tp); 3263+ delta = tp_filter_motion(tp, &raw, time); 3264+ 3265+ if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) { 3266+ unaccel = tp_normalize_delta(tp, raw); 3267+ tp_gesture_start(tp, time); 3268+ 3269+ struct device_coords coords[5]; 3270+ for (uint32_t i = 0; i < tp->nfingers_down; i++) { 3271+ coords[i] = tp->touches[i].point; 3272+ } 3273+ 3274+ if (calculate_swipe_cosine_similarity(tp, coords, tp->nfingers_down) == false) { 3275+ evdev_log_error(tp->device, "libinput gesture is unknown."); 3276+ } 3277+ 3278+ gesture_notify_swipe_private(&tp->device->base, time, 3279+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, 3280+ tp->gesture.finger_count, 3281+ &delta, &unaccel, coords, tp->nfingers_down); 3282+ } 3283+} 3284+ 3285 static void 3286 tp_gesture_handle_state_swipe(struct tp_dispatch *tp, uint64_t time) 3287 { 3288 struct device_float_coords raw; 3289+ struct sloted_coords_info raw_touches = {}; 3290 struct normalized_coords delta, unaccel; 3291 3292 raw = tp_get_average_touches_delta(tp); 3293 delta = tp_filter_motion(tp, &raw, time); 3294+ tp_get_raw_touches(tp, &raw_touches); 3295 3296 if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) { 3297 unaccel = tp_filter_motion_unaccelerated(tp, &raw, time); 3298@@ -1202,7 +1369,7 @@ 3299 gesture_notify_swipe(&tp->device->base, time, 3300 LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, 3301 tp->gesture.finger_count, 3302- &delta, &unaccel); 3303+ &delta, &unaccel, &raw_touches); 3304 } 3305 } 3306 3307@@ -1266,7 +1433,7 @@ 3308 tp_gesture_handle_state_scroll(tp, time); 3309 3310 if (tp->gesture.state == GESTURE_STATE_SWIPE) 3311- tp_gesture_handle_state_swipe(tp, time); 3312+ tp_gesture_handle_state_swipe_private(tp, time); 3313 3314 if (tp->gesture.state == GESTURE_STATE_PINCH) 3315 tp_gesture_handle_state_pinch(tp, time); 3316diff -Naur old/src/evdev-mt-touchpad-tap.c new/src/evdev-mt-touchpad-tap.c 3317--- old/src/evdev-mt-touchpad-tap.c 2021-01-01 00:00:00.000000000 +0000 3318+++ new/src/evdev-mt-touchpad-tap.c 2021-01-01 00:00:00.000000000 +0000 3319@@ -88,6 +88,7 @@ 3320 CASE_RETURN_STRING(TAP_STATE_2FGTAP_DRAGGING_2); 3321 CASE_RETURN_STRING(TAP_STATE_3FGTAP_DRAGGING_2); 3322 CASE_RETURN_STRING(TAP_STATE_DEAD); 3323+ CASE_RETURN_STRING(TAP_STATE_HOLDING); 3324 } 3325 return NULL; 3326 } 3327@@ -125,6 +126,10 @@ 3328 int nfingers, 3329 enum libinput_button_state state) 3330 { 3331+ if (tp->tap.state == TAP_STATE_IDLE) { 3332+ return; 3333+ } 3334+ 3335 int32_t button; 3336 int32_t button_map[2][3] = { 3337 { BTN_LEFT, BTN_RIGHT, BTN_MIDDLE }, 3338@@ -138,12 +143,16 @@ 3339 3340 button = button_map[tp->tap.map][nfingers - 1]; 3341 3342+ if (tp->device->key_count[button] == 0 && 3343+ state == LIBINPUT_BUTTON_STATE_RELEASED) 3344+ return; 3345+ 3346 if (state == LIBINPUT_BUTTON_STATE_PRESSED) 3347 tp->tap.buttons_pressed |= (1 << nfingers); 3348 else 3349 tp->tap.buttons_pressed &= ~(1 << nfingers); 3350 3351- evdev_pointer_notify_button(tp->device, 3352+ evdev_pointer_notify_tap(tp->device, 3353 time, 3354 button, 3355 state); 3356@@ -264,6 +273,10 @@ 3357 tp->tap.nfingers_down--; 3358 t->tap.state = TAP_TOUCH_STATE_DEAD; 3359 tp_tap_clear_timer(tp); 3360+ tp_tap_notify(tp, 3361+ tp->tap.saved_press_time, 3362+ 1, 3363+ LIBINPUT_BUTTON_STATE_PRESSED); 3364 break; 3365 case TAP_EVENT_PALM: 3366 tp->tap.state = TAP_STATE_IDLE; 3367@@ -290,8 +303,48 @@ 3368 tp->tap.state = TAP_STATE_IDLE; 3369 break; 3370 case TAP_EVENT_MOTION: 3371+ tp->tap.state = TAP_STATE_HOLDING; 3372+ break; 3373+ case TAP_EVENT_TIMEOUT: 3374+ break; 3375+ case TAP_EVENT_BUTTON: 3376+ tp->tap.state = TAP_STATE_DEAD; 3377+ break; 3378+ case TAP_EVENT_THUMB: 3379+ tp->tap.state = TAP_STATE_IDLE; 3380+ t->tap.is_thumb = true; 3381+ tp->tap.nfingers_down--; 3382+ t->tap.state = TAP_TOUCH_STATE_DEAD; 3383+ break; 3384+ case TAP_EVENT_PALM: 3385+ tp->tap.state = TAP_STATE_IDLE; 3386+ break; 3387+ case TAP_EVENT_PALM_UP: 3388+ break; 3389+ } 3390+ if ((tp->tap.state != TAP_STATE_HOLDING) && (tp->tap.state != TAP_STATE_HOLD)) { 3391+ tp_tap_notify(tp, 3392+ tp->tap.saved_press_time, 3393+ 1, 3394+ LIBINPUT_BUTTON_STATE_RELEASED); 3395+ } 3396+} 3397+ 3398+static void 3399+tp_tap_holding_handle_event(struct tp_dispatch *tp, 3400+ struct tp_touch *t, 3401+ enum tap_event event, uint64_t time) 3402+{ 3403+ 3404+ switch (event) { 3405+ case TAP_EVENT_TOUCH: 3406 tp_tap_move_to_dead(tp, t); 3407 break; 3408+ case TAP_EVENT_RELEASE: 3409+ tp->tap.state = TAP_STATE_IDLE; 3410+ break; 3411+ case TAP_EVENT_MOTION: 3412+ break; 3413 case TAP_EVENT_TIMEOUT: 3414 break; 3415 case TAP_EVENT_BUTTON: 3416@@ -309,6 +362,12 @@ 3417 case TAP_EVENT_PALM_UP: 3418 break; 3419 } 3420+ if (tp->tap.state != TAP_STATE_HOLDING) { 3421+ tp_tap_notify(tp, 3422+ tp->tap.saved_press_time, 3423+ 1, 3424+ LIBINPUT_BUTTON_STATE_RELEASED); 3425+ } 3426 } 3427 3428 static void 3429@@ -1143,6 +1202,9 @@ 3430 case TAP_STATE_DEAD: 3431 tp_tap_dead_handle_event(tp, t, event, time); 3432 break; 3433+ case TAP_STATE_HOLDING: 3434+ tp_tap_holding_handle_event(tp, t, event, time); 3435+ break; 3436 } 3437 3438 if (tp->tap.state == TAP_STATE_IDLE || tp->tap.state == TAP_STATE_DEAD) 3439@@ -1427,23 +1489,7 @@ 3440 static enum libinput_config_tap_state 3441 tp_tap_default(struct evdev_device *evdev) 3442 { 3443- /** 3444- * If we don't have a left button we must have tapping enabled by 3445- * default. 3446- */ 3447- if (!libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_LEFT)) 3448- return LIBINPUT_CONFIG_TAP_ENABLED; 3449- 3450- /** 3451- * Tapping is disabled by default for two reasons: 3452- * * if you don't know that tapping is a thing (or enabled by 3453- * default), you get spurious mouse events that make the desktop 3454- * feel buggy. 3455- * * if you do know what tapping is and you want it, you 3456- * usually know where to enable it, or at least you can search for 3457- * it. 3458- */ 3459- return LIBINPUT_CONFIG_TAP_DISABLED; 3460+ return LIBINPUT_CONFIG_TAP_ENABLED; 3461 } 3462 3463 static enum libinput_config_tap_state 3464@@ -1507,7 +1553,7 @@ 3465 static inline enum libinput_config_drag_state 3466 tp_drag_default(struct evdev_device *device) 3467 { 3468- return LIBINPUT_CONFIG_DRAG_ENABLED; 3469+ return LIBINPUT_CONFIG_DRAG_DISABLED; 3470 } 3471 3472 static enum libinput_config_drag_state 3473@@ -1669,3 +1715,63 @@ 3474 return false; 3475 } 3476 } 3477+ 3478+void 3479+tp_tap_original_down(struct tp_dispatch *tp, 3480+ struct tp_touch *t, 3481+ uint64_t time) 3482+{ 3483+ struct libinput_device *base = &tp->device->base; 3484+ struct evdev_device *device = tp->device; 3485+ int slot_idx = tp->slot; 3486+ int seat_slot = t->seat_slot; 3487+ int32_t pressure = t->pressure; 3488+ int tool_type = t->tool_type; 3489+ struct device_coords point; 3490+ struct device_coord_rect rect; 3491+ point = t->point; 3492+ struct touch_axis axis; 3493+ axis.major = t->major; 3494+ axis.minor = t->minor; 3495+ rect = t->tool_rect; 3496+ evdev_transform_absolute_rect(device, &rect); 3497+ touchpad_notify_touch_down(base, time, slot_idx, seat_slot, pressure, tool_type, axis, &point, &rect); 3498+} 3499+ 3500+void 3501+tp_tap_original_up(struct tp_dispatch *tp, 3502+ struct tp_touch *t, 3503+ uint64_t time) 3504+{ 3505+ struct libinput_device *base = &tp->device->base; 3506+ int slot_idx = tp->slot; 3507+ int seat_slot = t->seat_slot; 3508+ t->seat_slot = -1; 3509+ int tool_type = t->tool_type; 3510+ struct touch_axis axis; 3511+ axis.major = t->major; 3512+ axis.minor = t->minor; 3513+ touchpad_notify_touch_up(base, time, slot_idx, seat_slot, tool_type, axis); 3514+} 3515+ 3516+void 3517+tp_tap_original_motion(struct tp_dispatch *tp, 3518+ struct tp_touch *t, 3519+ uint64_t time) 3520+{ 3521+ struct libinput_device *base = &tp->device->base; 3522+ struct evdev_device *device = tp->device; 3523+ int seat_slot = t->seat_slot; 3524+ int slot_idx = tp->slot; 3525+ int32_t pressure = t->pressure; 3526+ int tool_type = t->tool_type; 3527+ struct device_coords point; 3528+ struct device_coord_rect rect; 3529+ point = t->point; 3530+ struct touch_axis axis; 3531+ axis.major = t->major; 3532+ axis.minor = t->minor; 3533+ rect = t->tool_rect; 3534+ evdev_transform_absolute_rect(device, &rect); 3535+ touchpad_notify_touch_motion(base, time, slot_idx, seat_slot, pressure, tool_type, axis, &point, &rect); 3536+} 3537\ No newline at end of file 3538diff -Naur old/src/evdev-mt-touchpad.c new/src/evdev-mt-touchpad.c 3539--- old/src/evdev-mt-touchpad.c 2021-01-01 00:00:00.000000000 +0000 3540+++ new/src/evdev-mt-touchpad.c 2021-01-01 00:00:00.000000000 +0000 3541@@ -311,6 +311,35 @@ 3542 } 3543 3544 static inline void 3545+tp_tool_key_set(struct tp_dispatch *tp, 3546+ unsigned int code, 3547+ bool is_press) 3548+{ 3549+ unsigned int shift = 0; 3550+ 3551+ switch (code) { 3552+ case BTN_TOOL_PEN: 3553+ case BTN_TOOL_RUBBER: 3554+ case BTN_TOOL_BRUSH: 3555+ case BTN_TOOL_PENCIL: 3556+ case BTN_TOOL_AIRBRUSH: 3557+ case BTN_TOOL_FINGER: 3558+ case BTN_TOOL_MOUSE: 3559+ case BTN_TOOL_LENS: 3560+ shift = code - BTN_TOOL_PEN; 3561+ break; 3562+ default: 3563+ return; 3564+ } 3565+ 3566+ if (is_press) { 3567+ tp->tool_touches |= 0x1 << shift; 3568+ } else { 3569+ tp->tool_touches &= ~(0x1 << shift); 3570+ } 3571+} 3572+ 3573+static inline void 3574 tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) 3575 { 3576 if (t->state == TOUCH_BEGIN || 3577@@ -343,6 +372,7 @@ 3578 t->speed.last_speed = 0; 3579 t->speed.exceeded_count = 0; 3580 t->hysteresis.x_motion_history = 0; 3581+ t->seat_slot = -1; 3582 tp->queued |= TOUCHPAD_EVENT_MOTION; 3583 } 3584 3585@@ -496,6 +526,81 @@ 3586 return absinfo->maximum - (value - absinfo->minimum); 3587 } 3588 3589+void tp_ext_post_event(struct tp_dispatch* dispatch, bool is_up, uint64_t time) 3590+{ 3591+ struct tp_touch * t = tp_current_touch(dispatch); 3592+ int seat_slot = t->seat_slot; 3593+ if (is_up) { 3594+ if (seat_slot == -1) { 3595+ return; 3596+ } 3597+ 3598+ dispatch->orginal.active_slot_count--; 3599+ if (dispatch->orginal.active_slot_count < 0) { 3600+ dispatch->orginal.active_slot_count = 0; 3601+ } 3602+ 3603+ if (dispatch->orginal.active_slot_count == 0) { 3604+ dispatch->orginal.seat_slot_id = 0; 3605+ } 3606+ 3607+ tp_tap_original_up(dispatch, t, time); 3608+ return; 3609+ } 3610+ 3611+ if (seat_slot == -1) { 3612+ t->seat_slot = dispatch->orginal.seat_slot_id++; 3613+ dispatch->orginal.active_slot_count++; 3614+ 3615+ tp_tap_original_down(dispatch, t, time); 3616+ return; 3617+ } 3618+ 3619+ tp_tap_original_motion(dispatch, t, time); 3620+} 3621+ 3622+void tp_ext_on_xy_update(struct tp_dispatch* dispatch) 3623+{ 3624+ dispatch->orginal.xy_updated = true; 3625+} 3626+ 3627+void tp_ext_on_mt_slot(struct tp_dispatch* dispatch, uint64_t time) 3628+{ 3629+ if (dispatch->orginal.xy_updated) { 3630+ dispatch->orginal.xy_updated = false; 3631+ tp_ext_post_event(dispatch, false, time); 3632+ return; 3633+ }; 3634+} 3635+ 3636+void tp_ext_before_new_touch(struct tp_dispatch* dispatch, uint64_t time) 3637+{ 3638+ if (dispatch->orginal.xy_updated) { 3639+ dispatch->orginal.xy_updated = false; 3640+ tp_ext_post_event(dispatch, false, time); 3641+ return; 3642+ }; 3643+} 3644+ 3645+void tp_ext_before_delete_touch(struct tp_dispatch* dispatch, uint64_t time) 3646+{ 3647+ if (dispatch->orginal.xy_updated) { 3648+ dispatch->orginal.xy_updated = false; 3649+ tp_ext_post_event(dispatch, false, time); 3650+ }; 3651+ 3652+ tp_ext_post_event(dispatch, true, time); 3653+} 3654+ 3655+void tp_ext_on_sync(struct tp_dispatch* dispatch, uint64_t time) 3656+{ 3657+ if (dispatch->orginal.xy_updated) { 3658+ dispatch->orginal.xy_updated = false; 3659+ tp_ext_post_event(dispatch, false, time); 3660+ return; 3661+ }; 3662+} 3663+ 3664 static void 3665 tp_process_absolute(struct tp_dispatch *tp, 3666 const struct input_event *e, 3667@@ -505,6 +610,7 @@ 3668 3669 switch(e->code) { 3670 case ABS_MT_POSITION_X: 3671+ tp_ext_on_xy_update(tp); 3672 evdev_device_check_abs_axis_range(tp->device, 3673 e->code, 3674 e->value); 3675@@ -513,6 +619,7 @@ 3676 tp->queued |= TOUCHPAD_EVENT_MOTION; 3677 break; 3678 case ABS_MT_POSITION_Y: 3679+ tp_ext_on_xy_update(tp); 3680 evdev_device_check_abs_axis_range(tp->device, 3681 e->code, 3682 e->value); 3683@@ -521,14 +628,17 @@ 3684 tp->queued |= TOUCHPAD_EVENT_MOTION; 3685 break; 3686 case ABS_MT_SLOT: 3687+ tp_ext_on_mt_slot(tp, time); 3688 tp->slot = e->value; 3689 break; 3690 case ABS_MT_TRACKING_ID: 3691 if (e->value != -1) { 3692+ tp_ext_before_new_touch(tp, time); 3693 tp->nactive_slots += 1; 3694 tp_new_touch(tp, t, time); 3695 } else { 3696 assert(tp->nactive_slots >= 1); 3697+ tp_ext_before_delete_touch(tp, time); 3698 tp->nactive_slots -= 1; 3699 tp_end_sequence(tp, t, time); 3700 } 3701@@ -540,6 +650,7 @@ 3702 break; 3703 case ABS_MT_TOOL_TYPE: 3704 t->is_tool_palm = e->value == MT_TOOL_PALM; 3705+ t->tool_type = e->value; 3706 t->dirty = true; 3707 tp->queued |= TOUCHPAD_EVENT_OTHERAXIS; 3708 break; 3709@@ -553,6 +664,26 @@ 3710 t->dirty = true; 3711 tp->queued |= TOUCHPAD_EVENT_OTHERAXIS; 3712 break; 3713+ case ABS_MT_WIDTH_MAJOR: 3714+ t->tool_rect.w = e->value; 3715+ t->dirty = true; 3716+ tp->queued |= TOUCHPAD_EVENT_OTHERAXIS; 3717+ break; 3718+ case ABS_MT_WIDTH_MINOR: 3719+ t->tool_rect.h = e->value; 3720+ t->dirty = true; 3721+ tp->queued |= TOUCHPAD_EVENT_OTHERAXIS; 3722+ break; 3723+ case ABS_MT_TOOL_X: 3724+ t->tool_rect.x = e->value; 3725+ t->dirty = true; 3726+ tp->queued |= TOUCHPAD_EVENT_OTHERAXIS; 3727+ break; 3728+ case ABS_MT_TOOL_Y: 3729+ t->tool_rect.y = e->value; 3730+ t->dirty = true; 3731+ tp->queued |= TOUCHPAD_EVENT_OTHERAXIS; 3732+ break; 3733 } 3734 } 3735 3736@@ -765,6 +896,20 @@ 3737 tp_process_trackpoint_button(tp, e, time); 3738 break; 3739 } 3740+ 3741+ switch (e->code) { 3742+ case BTN_TOOL_PEN: 3743+ case BTN_TOOL_RUBBER: 3744+ case BTN_TOOL_BRUSH: 3745+ case BTN_TOOL_PENCIL: 3746+ case BTN_TOOL_AIRBRUSH: 3747+ case BTN_TOOL_FINGER: 3748+ case BTN_TOOL_MOUSE: 3749+ case BTN_TOOL_LENS: 3750+ tp_tool_key_set(tp, e->code, !!e->value); 3751+ default: 3752+ break; 3753+ } 3754 } 3755 3756 static void 3757@@ -1961,6 +2106,7 @@ 3758 tp_process_msc(tp, e, time); 3759 break; 3760 case EV_SYN: 3761+ tp_ext_on_sync(tp, time); 3762 tp_handle_state(tp, time); 3763 #if 0 3764 tp_debug_touch_state(tp, device); 3765@@ -2855,6 +3001,8 @@ 3766 t->tp = tp; 3767 t->has_ended = true; 3768 t->index = index; 3769+ t->seat_slot = -1; 3770+ t->tool_type = -1; 3771 } 3772 3773 static inline void 3774@@ -3692,6 +3840,10 @@ 3775 if (tp->gesture.enabled) 3776 device->seat_caps |= EVDEV_DEVICE_GESTURE; 3777 3778+ tp->orginal.seat_slot_id = 0; 3779+ tp->orginal.active_slot_count = 0; 3780+ tp->orginal.xy_updated = 0; 3781+ 3782 return true; 3783 } 3784 3785@@ -3875,6 +4027,14 @@ 3786 3787 tp = zalloc(sizeof *tp); 3788 3789+ const struct input_absinfo* absInfo = device->is_mt ? libevdev_get_abs_info(device->evdev, ABS_MT_PRESSURE) 3790+ : libevdev_get_abs_info(device->evdev, ABS_PRESSURE); 3791+ if (absInfo == NULL) { 3792+ device->pressureMax = 0.0; 3793+ } else { 3794+ device->pressureMax = absInfo->maximum; 3795+ } 3796+ 3797 if (!tp_init(tp, device)) { 3798 tp_interface_destroy(&tp->base); 3799 return NULL; 3800@@ -3892,3 +4052,27 @@ 3801 3802 return &tp->base; 3803 } 3804+ 3805+bool 3806+evdev_device_touchpad_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType) 3807+{ 3808+ struct tp_dispatch *tp = tp_dispatch(device->dispatch); 3809+ 3810+ unsigned int shift = 0; 3811+ switch (btnToolType) { 3812+ case BTN_TOOL_PEN: 3813+ case BTN_TOOL_RUBBER: 3814+ case BTN_TOOL_BRUSH: 3815+ case BTN_TOOL_PENCIL: 3816+ case BTN_TOOL_AIRBRUSH: 3817+ case BTN_TOOL_FINGER: 3818+ case BTN_TOOL_MOUSE: 3819+ case BTN_TOOL_LENS: 3820+ shift = btnToolType - BTN_TOOL_PEN; 3821+ break; 3822+ default: 3823+ return false; 3824+ } 3825+ 3826+ return (tp->tool_touches >> shift) & 0x1; 3827+} 3828diff -Naur old/src/evdev-mt-touchpad.h new/src/evdev-mt-touchpad.h 3829--- old/src/evdev-mt-touchpad.h 2021-01-01 00:00:00.000000000 +0000 3830+++ new/src/evdev-mt-touchpad.h 2021-01-01 00:00:00.000000000 +0000 3831@@ -132,6 +132,7 @@ 3832 TAP_STATE_2FGTAP_DRAGGING_2, 3833 TAP_STATE_3FGTAP_DRAGGING_2, 3834 TAP_STATE_DEAD, /**< finger count exceeded */ 3835+ TAP_STATE_HOLDING, 3836 }; 3837 3838 enum tp_tap_touch_state { 3839@@ -192,10 +193,14 @@ 3840 int pressure; 3841 bool is_tool_palm; /* MT_TOOL_PALM */ 3842 int major, minor; 3843+ struct device_coord_rect tool_rect; 3844 3845 bool was_down; /* if distance == 0, false for pure hovering 3846 touches */ 3847 3848+ int seat_slot; 3849+ int tool_type; 3850+ 3851 struct { 3852 /* A quirk mostly used on Synaptics touchpads. In a 3853 transition to/from fake touches > num_slots, the current 3854@@ -310,6 +315,17 @@ 3855 */ 3856 unsigned int fake_touches; 3857 3858+ /* bit 0: BTN_TOOL_PEN 3859+ * bit 1: BTN_TOOL_RUBBER 3860+ * bit 2: BTN_TOOL_BRUSH 3861+ * bit 3: BTN_TOOL_PENCIL 3862+ * bit 4: BTN_TOOL_AIRBRUSH 3863+ * bit 5: BTN_TOOL_FINGER 3864+ * bit 6: BTN_TOOL_MOUSE 3865+ * bit 7: BTN_TOOL_LENS 3866+ */ 3867+ unsigned int tool_touches; 3868+ 3869 struct { 3870 bool detection_disabled; 3871 struct ratelimit warning; 3872@@ -532,6 +548,12 @@ 3873 struct evdev_device *tablet_device; 3874 bool tablet_left_handed_state; 3875 } left_handed; 3876+ 3877+ struct { 3878+ int seat_slot_id; 3879+ int active_slot_count; 3880+ int xy_updated; 3881+ } orginal; 3882 }; 3883 3884 static inline struct tp_dispatch* 3885@@ -762,4 +784,19 @@ 3886 struct tp_touch* 3887 tp_thumb_get_touch(struct tp_dispatch *tp); 3888 3889+void 3890+tp_tap_original_down(struct tp_dispatch *tp, 3891+ struct tp_touch *t, 3892+ uint64_t time); 3893+ 3894+void 3895+tp_tap_original_up(struct tp_dispatch *tp, 3896+ struct tp_touch *t, 3897+ uint64_t time); 3898+ 3899+void 3900+tp_tap_original_motion(struct tp_dispatch *tp, 3901+ struct tp_touch *t, 3902+ uint64_t time); 3903+ 3904 #endif 3905diff -Naur old/src/evdev-tablet.c new/src/evdev-tablet.c 3906--- old/src/evdev-tablet.c 2021-01-01 00:00:00.000000000 +0000 3907+++ new/src/evdev-tablet.c 2021-01-01 00:00:00.000000000 +0000 3908@@ -219,6 +219,7 @@ 3909 case ABS_TILT_Y: 3910 case ABS_DISTANCE: 3911 case ABS_WHEEL: 3912+ case ABS_MT_TOOL_TYPE: 3913 axis = evcode_to_axis(e->code); 3914 if (axis == LIBINPUT_TABLET_TOOL_AXIS_NONE) { 3915 evdev_log_bug_libinput(device, 3916@@ -230,7 +231,6 @@ 3917 tablet->prev_value[axis] = tablet->current_value[axis]; 3918 if (tablet_filter_axis_fuzz(tablet, device, e, axis)) 3919 break; 3920- 3921 tablet->current_value[axis] = e->value; 3922 set_bit(tablet->changed_axes, axis); 3923 tablet_set_status(tablet, TABLET_AXES_UPDATED); 3924@@ -1170,6 +1170,7 @@ 3925 .serial = serial, 3926 .tool_id = tool_id, 3927 .refcount = 1, 3928+ .pressure.mt_tool_type = tablet->current_value[LIBINPUT_TABLET_TOOL_AXIS_TYPE], 3929 }; 3930 3931 tool_set_pressure_thresholds(tablet, tool); 3932@@ -2119,11 +2120,11 @@ 3933 { 3934 struct tablet_dispatch *tablet = tablet_dispatch(device->dispatch); 3935 bool is_touchscreen, is_ext_touchpad; 3936- 3937+/* 3938 if (libinput_device_get_device_group(&device->base) != 3939 libinput_device_get_device_group(&added_device->base)) 3940 return; 3941- 3942+*/ 3943 is_touchscreen = evdev_device_has_capability(added_device, 3944 LIBINPUT_DEVICE_CAP_TOUCH); 3945 is_ext_touchpad = evdev_device_has_capability(added_device, 3946@@ -2442,6 +2443,34 @@ 3947 return true; 3948 } 3949 3950+static void 3951+tablet_reset_abs_resolution(struct evdev_device *device) 3952+{ 3953+ if (!device->abs.is_fake_resolution) { 3954+ return; 3955+ } 3956+ struct libevdev *evdev = device->evdev; 3957+ const struct input_absinfo *absy; 3958+ const struct input_absinfo *absx; 3959+ size_t widthmm = 271; 3960+ size_t heightmm = 170; 3961+ size_t xres = 0; 3962+ size_t yres = 0; 3963+ 3964+ absx = libevdev_get_abs_info(evdev, ABS_X); 3965+ absy = libevdev_get_abs_info(evdev, ABS_Y); 3966+ xres = (absx->maximum - absx->minimum) / widthmm; 3967+ yres = (absy->maximum - absy->minimum) / heightmm; 3968+ if (xres == 0 || yres == 0) { 3969+ return; 3970+ } 3971+ libevdev_set_abs_resolution(evdev, ABS_X, xres); 3972+ libevdev_set_abs_resolution(evdev, ABS_Y, yres); 3973+ device->abs.is_fake_resolution = false; 3974+ libinput_log_printf("\t\tdevice:%s no resolution or size hints, assuming a size of %dx%d mm\n", 3975+ device->devname, widthmm, heightmm); 3976+} 3977+ 3978 static int 3979 tablet_init(struct tablet_dispatch *tablet, 3980 struct evdev_device *device) 3981@@ -2456,6 +2485,7 @@ 3982 tablet->status = TABLET_NONE; 3983 tablet->current_tool.type = LIBINPUT_TOOL_NONE; 3984 list_init(&tablet->tool_list); 3985+ tablet_reset_abs_resolution(device); 3986 3987 if (tablet_reject_device(device)) 3988 return -1; 3989diff -Naur old/src/evdev-tablet.h new/src/evdev-tablet.h 3990--- old/src/evdev-tablet.h 2021-01-01 00:00:00.000000000 +0000 3991+++ new/src/evdev-tablet.h 2021-01-01 00:00:00.000000000 +0000 3992@@ -152,6 +152,9 @@ 3993 case ABS_WHEEL: 3994 axis = LIBINPUT_TABLET_TOOL_AXIS_SLIDER; 3995 break; 3996+ case ABS_MT_TOOL_TYPE: 3997+ axis = LIBINPUT_TABLET_TOOL_AXIS_TYPE; 3998+ break; 3999 default: 4000 axis = LIBINPUT_TABLET_TOOL_AXIS_NONE; 4001 break; 4002@@ -210,6 +213,9 @@ 4003 case LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR: 4004 evcode = ABS_MT_TOUCH_MAJOR; 4005 break; 4006+ case LIBINPUT_TABLET_TOOL_AXIS_TYPE: 4007+ evcode = ABS_MT_TOOL_TYPE; 4008+ break; 4009 case LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR: 4010 evcode = ABS_MT_TOUCH_MINOR; 4011 break; 4012diff -Naur old/src/evdev.c new/src/evdev.c 4013--- old/src/evdev.c 2021-01-01 00:00:00.000000000 +0000 4014+++ new/src/evdev.c 2021-01-01 00:00:00.000000000 +0000 4015@@ -52,25 +52,7 @@ 4016 #define DEFAULT_WHEEL_CLICK_ANGLE 15 4017 #define DEFAULT_BUTTON_SCROLL_TIMEOUT ms2us(200) 4018 4019-enum evdev_device_udev_tags { 4020- EVDEV_UDEV_TAG_INPUT = bit(0), 4021- EVDEV_UDEV_TAG_KEYBOARD = bit(1), 4022- EVDEV_UDEV_TAG_MOUSE = bit(2), 4023- EVDEV_UDEV_TAG_TOUCHPAD = bit(3), 4024- EVDEV_UDEV_TAG_TOUCHSCREEN = bit(4), 4025- EVDEV_UDEV_TAG_TABLET = bit(5), 4026- EVDEV_UDEV_TAG_JOYSTICK = bit(6), 4027- EVDEV_UDEV_TAG_ACCELEROMETER = bit(7), 4028- EVDEV_UDEV_TAG_TABLET_PAD = bit(8), 4029- EVDEV_UDEV_TAG_POINTINGSTICK = bit(9), 4030- EVDEV_UDEV_TAG_TRACKBALL = bit(10), 4031- EVDEV_UDEV_TAG_SWITCH = bit(11), 4032-}; 4033 4034-struct evdev_udev_tag_match { 4035- const char *name; 4036- enum evdev_device_udev_tags tag; 4037-}; 4038 4039 static const struct evdev_udev_tag_match evdev_udev_tag_matches[] = { 4040 {"ID_INPUT", EVDEV_UDEV_TAG_INPUT}, 4041@@ -118,7 +100,12 @@ 4042 { 4043 int key_count; 4044 assert(code >= 0 && code < KEY_CNT); 4045- 4046+ if (code == BTN_LEFT) { 4047+ if (device->key_count[code] == pressed) { 4048+ return pressed; 4049+ } 4050+ } 4051+ 4052 if (pressed) { 4053 key_count = ++device->key_count[code]; 4054 } else { 4055@@ -190,6 +177,56 @@ 4056 } 4057 4058 static void 4059+evdev_pointer_post_button_touchpad(struct evdev_device *device, 4060+ uint64_t time, 4061+ unsigned int button, 4062+ enum libinput_button_state state) 4063+{ 4064+ int down_count; 4065+ 4066+ down_count = evdev_update_key_down_count(device, button, state); 4067+ 4068+ if ((state == LIBINPUT_BUTTON_STATE_PRESSED && down_count == 1) || 4069+ (state == LIBINPUT_BUTTON_STATE_RELEASED && down_count == 0)) { 4070+ pointer_notify_button_touchpad(&device->base, time, button, state); 4071+ 4072+ if (state == LIBINPUT_BUTTON_STATE_RELEASED) { 4073+ if (device->left_handed.change_to_enabled) 4074+ device->left_handed.change_to_enabled(device); 4075+ 4076+ if (device->scroll.change_scroll_method) 4077+ device->scroll.change_scroll_method(device); 4078+ } 4079+ } 4080+ 4081+} 4082+ 4083+static void 4084+evdev_pointer_post_tap(struct evdev_device *device, 4085+ uint64_t time, 4086+ unsigned int button, 4087+ enum libinput_button_state state) 4088+{ 4089+ int down_count; 4090+ 4091+ down_count = evdev_update_key_down_count(device, button, state); 4092+ 4093+ if ((state == LIBINPUT_BUTTON_STATE_PRESSED && down_count == 1) || 4094+ (state == LIBINPUT_BUTTON_STATE_RELEASED && down_count == 0)) { 4095+ pointer_notify_tap(&device->base, time, button, state); 4096+ 4097+ if (state == LIBINPUT_BUTTON_STATE_RELEASED) { 4098+ if (device->left_handed.change_to_enabled) 4099+ device->left_handed.change_to_enabled(device); 4100+ 4101+ if (device->scroll.change_scroll_method) 4102+ device->scroll.change_scroll_method(device); 4103+ } 4104+ } 4105+ 4106+} 4107+ 4108+static void 4109 evdev_button_scroll_timeout(uint64_t time, void *data) 4110 { 4111 struct evdev_device *device = data; 4112@@ -310,6 +347,36 @@ 4113 } 4114 4115 void 4116+evdev_pointer_notify_button_touchpad(struct evdev_device *device, 4117+ uint64_t time, 4118+ unsigned int button, 4119+ enum libinput_button_state state) 4120+{ 4121+ if (device->scroll.method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN && 4122+ button == device->scroll.button) { 4123+ evdev_button_scroll_button(device, time, state); 4124+ return; 4125+ } 4126+ 4127+ evdev_pointer_post_button_touchpad(device, time, button, state); 4128+} 4129+ 4130+void 4131+evdev_pointer_notify_tap(struct evdev_device *device, 4132+ uint64_t time, 4133+ unsigned int button, 4134+ enum libinput_button_state state) 4135+{ 4136+ if (device->scroll.method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN && 4137+ button == device->scroll.button) { 4138+ evdev_button_scroll_button(device, time, state); 4139+ return; 4140+ } 4141+ 4142+ evdev_pointer_post_tap(device, time, button, state); 4143+} 4144+ 4145+void 4146 evdev_device_led_update(struct evdev_device *device, enum libinput_led leds) 4147 { 4148 static const struct { 4149@@ -350,6 +417,17 @@ 4150 } 4151 4152 void 4153+evdev_transform_absolute_rect(struct evdev_device *device, 4154+ struct device_coord_rect *rect) 4155+{ 4156+ if (!device->abs.apply_calibration) 4157+ return; 4158+ 4159+ matrix_mult_vec(&device->abs.calibration, &rect->x, &rect->y); 4160+ matrix_mult_vec(&device->abs.calibration, &rect->w, &rect->h); 4161+} 4162+ 4163+void 4164 evdev_transform_relative(struct evdev_device *device, 4165 struct device_coords *point) 4166 { 4167@@ -365,6 +443,9 @@ 4168 static inline double 4169 scale_axis(const struct input_absinfo *absinfo, double val, double to_range) 4170 { 4171+ if (absinfo->maximum < absinfo->minimum) { 4172+ return 0.0; 4173+ } 4174 return (val - absinfo->minimum) * to_range / 4175 (absinfo->maximum - absinfo->minimum + 1); 4176 } 4177@@ -1850,6 +1931,9 @@ 4178 libevdev_disable_event_code(evdev, EV_ABS, REL_Z); 4179 } 4180 4181+static enum evdev_device_udev_tags 4182+update_device_capability(struct evdev_device *device); 4183+ 4184 static struct evdev_dispatch * 4185 evdev_configure_device(struct evdev_device *device) 4186 { 4187@@ -1859,11 +1943,17 @@ 4188 struct evdev_dispatch *dispatch; 4189 4190 udev_tags = evdev_device_get_udev_tags(device, device->udev_device); 4191+ libinput_log_printf("----evdev_configure_device tagged as supported input device---- %d \r\n", udev_tags); 4192 4193 if ((udev_tags & EVDEV_UDEV_TAG_INPUT) == 0 || 4194 (udev_tags & ~EVDEV_UDEV_TAG_INPUT) == 0) { 4195+ udev_tags = update_device_capability(device); 4196+ } 4197+ if ((udev_tags & EVDEV_UDEV_TAG_INPUT) == 0 || 4198+ (udev_tags & ~EVDEV_UDEV_TAG_INPUT) == 0) { 4199 evdev_log_info(device, 4200 "not tagged as supported input device\n"); 4201+ libinput_log_printf("----evdev_configure_device not tagged as supported input device---- \r\n"); 4202 return NULL; 4203 } 4204 4205@@ -1893,12 +1983,6 @@ 4206 evdev_disable_accelerometer_axes(device); 4207 } 4208 4209- if (udev_tags == (EVDEV_UDEV_TAG_INPUT|EVDEV_UDEV_TAG_JOYSTICK)) { 4210- evdev_log_info(device, 4211- "device is a joystick, ignoring\n"); 4212- return NULL; 4213- } 4214- 4215 if (evdev_reject_device(device)) { 4216 evdev_log_info(device, "was rejected\n"); 4217 return NULL; 4218@@ -1914,8 +1998,16 @@ 4219 udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN; 4220 } 4221 4222+ if (udev_tags & EVDEV_UDEV_TAG_JOYSTICK) { 4223+ libinput_log_printf("----evdev_configure_device--_LIBINPUT_JOYSTICK_BULID-- \r\n"); 4224+ dispatch = evdev_joystick_create(device); 4225+ device->seat_caps |= EVDEV_DEVICE_JOYSTICK; 4226+ return dispatch; 4227+ } 4228+ 4229 if (evdev_device_has_model_quirk(device, 4230 QUIRK_MODEL_DELL_CANVAS_TOTEM)) { 4231+ libinput_log_printf("----evdev_configure_device--_LIBINPUT_TOTEM_BULID-- \r\n"); 4232 dispatch = evdev_totem_create(device); 4233 device->seat_caps |= EVDEV_DEVICE_TABLET; 4234 evdev_log_info(device, "device is a totem\n"); 4235@@ -1931,6 +2023,7 @@ 4236 4237 /* libwacom assigns tablet _and_ tablet_pad to the pad devices */ 4238 if (udev_tags & EVDEV_UDEV_TAG_TABLET_PAD) { 4239+ libinput_log_printf("----evdev_configure_device--_LIBINPUT_TABLET_PAD_BULID-- \r\n"); 4240 dispatch = evdev_tablet_pad_create(device); 4241 device->seat_caps |= EVDEV_DEVICE_TABLET_PAD; 4242 evdev_log_info(device, "device is a tablet pad\n"); 4243@@ -1939,6 +2032,7 @@ 4244 } 4245 4246 if ((udev_tags & tablet_tags) == EVDEV_UDEV_TAG_TABLET) { 4247+ libinput_log_printf("----evdev_configure_device--_LIBINPUT_TABLET_BULID-- \r\n"); 4248 dispatch = evdev_tablet_create(device); 4249 device->seat_caps |= EVDEV_DEVICE_TABLET; 4250 evdev_log_info(device, "device is a tablet\n"); 4251@@ -1946,6 +2040,7 @@ 4252 } 4253 4254 if (udev_tags & EVDEV_UDEV_TAG_TOUCHPAD) { 4255+ libinput_log_printf("----evdev_configure_device--_LIBINPUT_TOUCHPAD_BULID-- \r\n"); 4256 if (udev_tags & EVDEV_UDEV_TAG_TABLET) 4257 evdev_tag_tablet_touchpad(device); 4258 /* whether velocity should be averaged, false by default */ 4259@@ -2423,6 +2518,18 @@ 4260 } 4261 4262 unsigned int 4263+evdev_device_get_id_bustype(struct evdev_device *device) 4264+{ 4265+ return libevdev_get_id_bustype(device->evdev); 4266+} 4267+ 4268+unsigned int 4269+evdev_device_get_id_version(struct evdev_device *device) 4270+{ 4271+ return libevdev_get_id_version(device->evdev); 4272+} 4273+ 4274+unsigned int 4275 evdev_device_get_id_product(struct evdev_device *device) 4276 { 4277 return libevdev_get_id_product(device->evdev); 4278@@ -2440,6 +2547,33 @@ 4279 return udev_device_ref(device->udev_device); 4280 } 4281 4282+enum evdev_device_udev_tags 4283+ evdev_device_get_udev_device_tags(struct evdev_device* device) 4284+{ 4285+ enum evdev_device_udev_tags udev_tags; 4286+ udev_tags = evdev_device_get_udev_tags(device, device->udev_device); 4287+ return udev_tags; 4288+} 4289+ 4290+int 4291+evdev_has_event_type(struct evdev_device *device, unsigned int type) 4292+{ 4293+ return libevdev_has_event_type(device->evdev, type); 4294+} 4295+ 4296+int 4297+evdev_get_event_value(struct evdev_device *device, unsigned int type, unsigned int code) 4298+{ 4299+ return libevdev_get_event_value(device->evdev, type, code); 4300+} 4301+ 4302+int 4303+evdev_kernel_set_led_value(struct evdev_device *device, unsigned int code, unsigned int state) 4304+{ 4305+ enum libevdev_led_value value = (state == 0 ? LIBEVDEV_LED_OFF : LIBEVDEV_LED_ON); 4306+ return libevdev_kernel_set_led_value(device->evdev, code, value); 4307+} 4308+ 4309 void 4310 evdev_device_set_default_calibration(struct evdev_device *device, 4311 const float calibration[6]) 4312@@ -2607,6 +2741,9 @@ 4313 return !!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD); 4314 case LIBINPUT_DEVICE_CAP_SWITCH: 4315 return !!(device->seat_caps & EVDEV_DEVICE_SWITCH); 4316+ case LIBINPUT_DEVICE_CAP_JOYSTICK: 4317+ return !!(device->seat_caps & EVDEV_DEVICE_JOYSTICK); 4318+ 4319 default: 4320 return false; 4321 } 4322@@ -3069,3 +3206,75 @@ 4323 #endif 4324 return has_left_handed; 4325 } 4326+ 4327+static inline bool 4328+is_touchscreen(const struct libevdev *evdev) 4329+{ 4330+ return (libevdev_has_event_type(evdev, EV_ABS) && 4331+ libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) && 4332+ libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y) && 4333+ libevdev_has_property(evdev, INPUT_PROP_DIRECT)); 4334+} 4335+ 4336+static inline bool 4337+is_mouse(const struct libevdev *evdev) 4338+{ 4339+ return (libevdev_has_event_type(evdev, EV_REL) && 4340+ libevdev_has_event_code(evdev, EV_REL, REL_X) && 4341+ libevdev_has_event_code(evdev, EV_REL, REL_Y)); 4342+} 4343+ 4344+static inline bool 4345+is_keyboard(const struct libevdev *evdev) 4346+{ 4347+ return (libevdev_has_event_type(evdev, EV_KEY) && 4348+ !libevdev_has_event_type(evdev, EV_ABS) && 4349+ !libevdev_has_event_type(evdev, EV_REL)); 4350+} 4351+ 4352+static inline bool 4353+is_touchpad(const struct libevdev *evdev) 4354+{ 4355+ return (libevdev_has_event_type(evdev, EV_ABS) && 4356+ libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X)); 4357+} 4358+ 4359+static inline bool 4360+is_switch(const struct libevdev *evdev) 4361+{ 4362+ return (libevdev_has_event_type(evdev, EV_SW)); 4363+} 4364+ 4365+is_tablet_tool(const struct libevdev *evdev) 4366+{ 4367+ return (libevdev_has_event_type(evdev, EV_KEY) && 4368+ (libevdev_has_event_code(evdev, EV_KEY, BTN_TOOL_PEN) || 4369+ libevdev_has_event_code(evdev, EV_KEY, BTN_STYLUS)) && 4370+ libevdev_has_event_type(evdev, EV_ABS) && 4371+ libevdev_has_event_code(evdev, EV_ABS, ABS_X) && 4372+ libevdev_has_event_code(evdev, EV_ABS, ABS_Y)); 4373+} 4374+ 4375+static enum evdev_device_udev_tags 4376+update_device_capability(struct evdev_device *device) 4377+{ 4378+ if (is_touchscreen(device->evdev)) { 4379+ return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_TOUCHSCREEN); 4380+ } 4381+ if (is_mouse(device->evdev)) { 4382+ return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_MOUSE); 4383+ } 4384+ if (is_keyboard(device->evdev)) { 4385+ return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_KEYBOARD); 4386+ } 4387+ if (is_tablet_tool(device->evdev)) { 4388+ return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_TABLET); 4389+ } 4390+ if (is_touchpad(device->evdev)) { 4391+ return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_TOUCHPAD); 4392+ } 4393+ if (is_switch(device->evdev)) { 4394+ return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_SWITCH); 4395+ } 4396+ return 0; 4397+} 4398diff -Naur old/src/evdev.h new/src/evdev.h 4399--- old/src/evdev.h 2021-01-01 00:00:00.000000000 +0000 4400+++ new/src/evdev.h 2021-01-01 00:00:00.000000000 +0000 4401@@ -61,6 +61,7 @@ 4402 EVDEV_DEVICE_TABLET_PAD = bit(4), 4403 EVDEV_DEVICE_GESTURE = bit(5), 4404 EVDEV_DEVICE_SWITCH = bit(6), 4405+ EVDEV_DEVICE_JOYSTICK = bit(7), 4406 }; 4407 4408 enum evdev_device_tags { 4409@@ -76,6 +77,11 @@ 4410 EVDEV_TAG_TABLET_TOUCHPAD = bit(9), 4411 }; 4412 4413+struct evdev_udev_tag_match { 4414+ const char* name; 4415+ enum evdev_device_udev_tags tag; 4416+}; 4417+ 4418 enum evdev_middlebutton_state { 4419 MIDDLEBUTTON_IDLE, 4420 MIDDLEBUTTON_LEFT_DOWN, 4421@@ -177,6 +183,7 @@ 4422 enum evdev_device_tags tags; 4423 bool is_mt; 4424 bool is_suspended; 4425+ int32_t pressureMax; 4426 int dpi; /* HW resolution */ 4427 double trackpoint_multiplier; /* trackpoint constant multiplier */ 4428 bool use_velocity_averaging; /* whether averaging should be applied on velocity calculation */ 4429@@ -271,6 +278,11 @@ 4430 uint32_t button_mask; 4431 uint64_t first_event_time; 4432 } middlebutton; 4433+ 4434+ struct { 4435+ int32_t seconds; 4436+ int32_t microseconds; 4437+ } sensor_timestamp; 4438 }; 4439 4440 static inline struct evdev_device * 4441@@ -355,6 +367,7 @@ 4442 DISPATCH_TABLET, 4443 DISPATCH_TABLET_PAD, 4444 DISPATCH_TOTEM, 4445+ DISPATCH_JOYSTICK, 4446 }; 4447 4448 struct evdev_dispatch { 4449@@ -408,6 +421,10 @@ 4450 struct device_coords *point); 4451 4452 void 4453+evdev_transform_absolute_rect(struct evdev_device *device, 4454+ struct device_coord_rect *rect); 4455+ 4456+void 4457 evdev_transform_relative(struct evdev_device *device, 4458 struct device_coords *point); 4459 4460@@ -432,12 +449,19 @@ 4461 evdev_device_init_pointer_acceleration(struct evdev_device *device, 4462 struct motion_filter *filter); 4463 4464+struct evdev_dispatch* 4465+evdev_joystick_create(struct evdev_device* device); 4466+ 4467+ 4468 struct evdev_dispatch * 4469 evdev_touchpad_create(struct evdev_device *device); 4470 4471 struct evdev_dispatch * 4472 evdev_mt_touchpad_create(struct evdev_device *device); 4473 4474+bool 4475+evdev_device_touchpad_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType); 4476+ 4477 struct evdev_dispatch * 4478 evdev_tablet_create(struct evdev_device *device); 4479 4480@@ -475,6 +499,12 @@ 4481 evdev_device_get_name(struct evdev_device *device); 4482 4483 unsigned int 4484+evdev_device_get_id_bustype(struct evdev_device *device); 4485+ 4486+unsigned int 4487+evdev_device_get_id_version(struct evdev_device *device); 4488+ 4489+unsigned int 4490 evdev_device_get_id_product(struct evdev_device *device); 4491 4492 unsigned int 4493@@ -483,6 +513,19 @@ 4494 struct udev_device * 4495 evdev_device_get_udev_device(struct evdev_device *device); 4496 4497+/** @brief 获取设备类型 */ 4498+enum evdev_device_udev_tags 4499+evdev_device_get_udev_device_tags(struct evdev_device* device); 4500+ 4501+int 4502+evdev_has_event_type(struct evdev_device *device, unsigned int type); 4503+ 4504+int 4505+evdev_get_event_value(struct evdev_device *device, unsigned int type, unsigned int code); 4506+ 4507+int 4508+evdev_kernel_set_led_value(struct evdev_device *device, unsigned int code, unsigned int state); 4509+ 4510 void 4511 evdev_device_set_default_calibration(struct evdev_device *device, 4512 const float calibration[6]); 4513@@ -508,6 +551,9 @@ 4514 int 4515 evdev_device_get_touch_count(struct evdev_device *device); 4516 4517+bool 4518+evdev_device_touch_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType); 4519+ 4520 int 4521 evdev_device_has_switch(struct evdev_device *device, 4522 enum libinput_switch sw); 4523@@ -562,6 +608,19 @@ 4524 uint64_t time, 4525 unsigned int button, 4526 enum libinput_button_state state); 4527+ 4528+void 4529+evdev_pointer_notify_button_touchpad(struct evdev_device *device, 4530+ uint64_t time, 4531+ unsigned int button, 4532+ enum libinput_button_state state); 4533+ 4534+void 4535+evdev_pointer_notify_tap(struct evdev_device *device, 4536+ uint64_t time, 4537+ unsigned int button, 4538+ enum libinput_button_state state); 4539+ 4540 void 4541 evdev_pointer_notify_physical_button(struct evdev_device *device, 4542 uint64_t time, 4543@@ -647,6 +706,9 @@ 4544 static inline double 4545 evdev_convert_to_mm(const struct input_absinfo *absinfo, double v) 4546 { 4547+ if (absinfo->resolution == 0){ 4548+ return 0.0; 4549+ } 4550 double value = v - absinfo->minimum; 4551 return value/absinfo->resolution; 4552 } 4553@@ -782,12 +844,15 @@ 4554 4555 if (!is_logged(evdev_libinput_context(device), priority)) 4556 return; 4557- 4558+ const char *name = evdev_device_get_sysname(device); 4559+ if (strchr(name, '%') != NULL) { 4560+ return; 4561+ } 4562 /* Anything info and above is user-visible, use the device name */ 4563 snprintf(buf, 4564 sizeof(buf), 4565 "%-7s - %s%s%s", 4566- evdev_device_get_sysname(device), 4567+ name, 4568 (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? device->log_prefix_name : "", 4569 (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ? ": " : "", 4570 format); 4571@@ -1029,7 +1094,8 @@ 4572 "Axis %#x value %d is outside expected range [%d, %d]\n" 4573 "See %s/absolute_coordinate_ranges.html for details\n", 4574 code, value, min, max, 4575- HTTP_DOC_LINK); 4576+ ""); 4577+ //HTTP_DOC_LINK); 4578 } 4579 } 4580 4581diff -Naur old/src/libinput-git-version.h new/src/libinput-git-version.h 4582--- old/src/libinput-git-version.h 1970-01-01 00:00:00.000000000 +0000 4583+++ new/src/libinput-git-version.h 2021-01-01 00:00:00.000000000 +0000 4584@@ -0,0 +1,3 @@ 4585+#pragma once 4586+ 4587+#define LIBINPUT_GIT_VERSION "@VCS_TAG@" 4588diff -Naur old/src/libinput-private.h new/src/libinput-private.h 4589--- old/src/libinput-private.h 2021-01-01 00:00:00.000000000 +0000 4590+++ new/src/libinput-private.h 2021-01-01 00:00:00.000000000 +0000 4591@@ -49,6 +49,12 @@ 4592 int x, y; 4593 }; 4594 4595+/* Size of touch point region (major and minor axes of ellipse) */ 4596+struct touch_axis { 4597+ int32_t major; 4598+ int32_t minor; 4599+}; 4600+ 4601 /* 4602 * A coordinate pair in device coordinates, capable of holding non discrete 4603 * values, this is necessary e.g. when device coordinates get averaged. 4604@@ -364,7 +370,8 @@ 4605 LIBINPUT_TABLET_TOOL_AXIS_SLIDER = 8, 4606 LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL = 9, 4607 LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR = 10, 4608- LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR = 11, 4609+ LIBINPUT_TABLET_TOOL_AXIS_TYPE = 11, 4610+ LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR = 12, 4611 }; 4612 4613 #define LIBINPUT_TABLET_TOOL_AXIS_MAX LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR 4614@@ -398,6 +405,7 @@ 4615 /* pressure_offset includes axis->minimum */ 4616 int offset; 4617 bool has_offset; 4618+ int32_t mt_tool_type; 4619 } pressure; 4620 }; 4621 4622@@ -431,6 +439,20 @@ 4623 void *notify_func_data; 4624 }; 4625 4626+struct joystick_axis_abs_infos { 4627+ struct libinput_event_joystick_axis_abs_info abs_throttle; 4628+ struct libinput_event_joystick_axis_abs_info abs_hat0x; 4629+ struct libinput_event_joystick_axis_abs_info abs_hat0y; 4630+ struct libinput_event_joystick_axis_abs_info abs_x; 4631+ struct libinput_event_joystick_axis_abs_info abs_y; 4632+ struct libinput_event_joystick_axis_abs_info abs_z; 4633+ struct libinput_event_joystick_axis_abs_info abs_rx; 4634+ struct libinput_event_joystick_axis_abs_info abs_ry; 4635+ struct libinput_event_joystick_axis_abs_info abs_rz; 4636+ struct libinput_event_joystick_axis_abs_info abs_gas; 4637+ struct libinput_event_joystick_axis_abs_info abs_brake; 4638+}; 4639+ 4640 typedef void (*libinput_source_dispatch_t)(void *data); 4641 4642 #define log_debug(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__) 4643@@ -562,6 +584,12 @@ 4644 const struct device_float_coords *raw); 4645 4646 void 4647+touchpad_pointer_notify_motion(struct libinput_device *device, 4648+ uint64_t time, 4649+ const struct normalized_coords *delta, 4650+ const struct device_float_coords *raw); 4651+ 4652+void 4653 pointer_notify_motion_absolute(struct libinput_device *device, 4654 uint64_t time, 4655 const struct device_coords *point); 4656@@ -573,6 +601,18 @@ 4657 enum libinput_button_state state); 4658 4659 void 4660+pointer_notify_button_touchpad(struct libinput_device *device, 4661+ uint64_t time, 4662+ int32_t button, 4663+ enum libinput_button_state state); 4664+ 4665+void 4666+pointer_notify_tap(struct libinput_device *device, 4667+ uint64_t time, 4668+ int32_t button, 4669+ enum libinput_button_state state); 4670+ 4671+void 4672 pointer_notify_axis_finger(struct libinput_device *device, 4673 uint64_t time, 4674 uint32_t axes, 4675@@ -602,20 +642,29 @@ 4676 uint64_t time, 4677 int32_t slot, 4678 int32_t seat_slot, 4679- const struct device_coords *point); 4680+ int32_t pressure, 4681+ const struct touch_axis *axis, 4682+ const struct device_coords *point, 4683+ int32_t tool_type, 4684+ const struct device_coord_rect *tool_rect); 4685 4686 void 4687 touch_notify_touch_motion(struct libinput_device *device, 4688 uint64_t time, 4689 int32_t slot, 4690 int32_t seat_slot, 4691- const struct device_coords *point); 4692+ int32_t pressure, 4693+ const struct touch_axis *axis, 4694+ const struct device_coords *point, 4695+ int32_t tool_type, 4696+ const struct device_coord_rect *tool_rect); 4697 4698 void 4699 touch_notify_touch_up(struct libinput_device *device, 4700 uint64_t time, 4701 int32_t slot, 4702- int32_t seat_slot); 4703+ int32_t seat_slot, 4704+ int32_t tool_type); 4705 4706 void 4707 touch_notify_touch_cancel(struct libinput_device *device, 4708@@ -628,12 +677,53 @@ 4709 uint64_t time); 4710 4711 void 4712+touchpad_notify_touch_down(struct libinput_device *device, 4713+ uint64_t time, 4714+ int32_t slot, 4715+ int32_t seat_slot, 4716+ int32_t pressure, 4717+ int32_t tool_type, 4718+ struct touch_axis axis, 4719+ const struct device_coords *point, 4720+ const struct device_coord_rect *tool_rect); 4721+ 4722+void 4723+touchpad_notify_touch_motion(struct libinput_device *device, 4724+ uint64_t time, 4725+ int32_t slot, 4726+ int32_t seat_slot, 4727+ int32_t pressure, 4728+ int32_t tool_type, 4729+ struct touch_axis axis, 4730+ const struct device_coords *point, 4731+ const struct device_coord_rect *tool_rect); 4732+ 4733+void 4734+touchpad_notify_touch_up(struct libinput_device *device, 4735+ uint64_t time, 4736+ int32_t slot, 4737+ int32_t seat_slot, 4738+ int32_t tool_type, 4739+ struct touch_axis axis); 4740+ 4741+void 4742 gesture_notify_swipe(struct libinput_device *device, 4743 uint64_t time, 4744 enum libinput_event_type type, 4745 int finger_count, 4746 const struct normalized_coords *delta, 4747- const struct normalized_coords *unaccel); 4748+ const struct normalized_coords *unaccel, 4749+ const struct sloted_coords_info *raw_touches); 4750+ 4751+void 4752+gesture_notify_swipe_private(struct libinput_device *device, 4753+ uint64_t time, 4754+ enum libinput_event_type type, 4755+ int finger_count, 4756+ const struct normalized_coords *delta, 4757+ const struct normalized_coords *unaccel, 4758+ struct device_coords *coords, 4759+ int coordsLen); 4760 4761 void 4762 gesture_notify_swipe_end(struct libinput_device *device, 4763@@ -733,6 +823,12 @@ 4764 enum libinput_switch sw, 4765 enum libinput_switch_state state); 4766 4767+void 4768+joysticks_notify_axis(struct libinput_device *device, 4769+ uint64_t time, 4770+ uint32_t axes, 4771+ const struct joystick_axis_abs_infos *axis_abs); 4772+ 4773 static inline uint64_t 4774 libinput_now(struct libinput *libinput) 4775 { 4776diff -Naur old/src/libinput-util.c new/src/libinput-util.c 4777--- old/src/libinput-util.c 1970-01-01 00:00:00.000000000 +0000 4778+++ new/src/libinput-util.c 2021-01-01 00:00:00.000000000 +0000 4779@@ -0,0 +1,102 @@ 4780+/* 4781+ * Copyright © 2008-2011 Kristian Høgsberg 4782+ * Copyright © 2011 Intel Corporation 4783+ * Copyright © 2013-2015 Red Hat, Inc. 4784+ * 4785+ * Permission is hereby granted, free of charge, to any person obtaining a 4786+ * copy of this software and associated documentation files (the "Software"), 4787+ * to deal in the Software without restriction, including without limitation 4788+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 4789+ * and/or sell copies of the Software, and to permit persons to whom the 4790+ * Software is furnished to do so, subject to the following conditions: 4791+ * 4792+ * The above copyright notice and this permission notice (including the next 4793+ * paragraph) shall be included in all copies or substantial portions of the 4794+ * Software. 4795+ * 4796+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 4797+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 4798+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 4799+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 4800+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 4801+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 4802+ * DEALINGS IN THE SOFTWARE. 4803+ */ 4804+ 4805+/* 4806+ * This list data structure is verbatim copy from wayland-util.h from the 4807+ * Wayland project; except that wl_ prefix has been removed. 4808+ */ 4809+ 4810+#include "libinput-util.h" 4811+ 4812+#ifdef HAVE_LIBINPUT_LOG_ENABLE 4813+ 4814+static FILE* p_log_fp = NULL; 4815+ 4816+FILE *libinput_get_log_fp() 4817+{ 4818+ if (p_log_fp == NULL) { 4819+ const char *pLogDir = getenv("LIBINPUT_LOG_DIR"); 4820+ if (pLogDir == NULL) { 4821+ pLogDir = (char *)_LIBINPUT_LOG_DIR; 4822+ } 4823+ 4824+ const int r = mkdir(pLogDir, 0755); 4825+ if (r < 0 && errno != EEXIST) { 4826+ const int saved_errno = errno; 4827+ printf("could not create %s, errno: %d\n", pLogDir, saved_errno); 4828+ return NULL; 4829+ } 4830+ 4831+ const char *p_log_path = getenv("LIBINPUT_LOG_PATH"); 4832+ if (p_log_path == NULL) { 4833+ p_log_path = (char *)_LIBINPUT_LOG_PATH; 4834+ } 4835+ p_log_fp = fopen(p_log_path, "w+"); 4836+ } 4837+ 4838+ return p_log_fp; 4839+} 4840+ 4841+void libinput_log_printf(const char* fmt, ...) 4842+{ 4843+ p_log_fp = libinput_get_log_fp(); 4844+#ifdef HAVE_LIBINPUT_LOG_CONSOLE_ENABLE 4845+ char buf[1024] = {0}; 4846+ 4847+ va_list args; 4848+ va_start(args, fmt); 4849+ vsprintf(buf, fmt, args); 4850+ va_end(args); 4851+ buf[1024 - 1] = '\0'; 4852+ 4853+ printf("%s\n", buf); 4854+ 4855+ if (p_log_fp != NULL) { 4856+ fputs(buf, p_log_fp); 4857+ fflush(p_log_fp); 4858+ } 4859+#else 4860+ if (p_log_fp != NULL) { 4861+ va_list args; 4862+ va_start(args, fmt); 4863+ vfprintf(p_log_fp, fmt, args); 4864+ va_end(args); 4865+ fflush(p_log_fp); 4866+ } 4867+#endif 4868+} 4869+ 4870+uint64_t getMicrotime() 4871+{ 4872+ struct timeval currentTime; 4873+ gettimeofday(¤tTime, NULL); 4874+ return currentTime.tv_sec * 1000000 + currentTime.tv_usec; 4875+} 4876+ 4877+uint64_t getTranTime(struct input_event *event) 4878+{ 4879+ return event->input_event_sec * 1000000 + event->input_event_usec; 4880+} 4881+#endif 4882diff -Naur old/src/libinput-util.h new/src/libinput-util.h 4883--- old/src/libinput-util.h 2021-01-01 00:00:00.000000000 +0000 4884+++ new/src/libinput-util.h 2021-01-01 00:00:00.000000000 +0000 4885@@ -27,10 +27,9 @@ 4886 4887 #include "config.h" 4888 4889-#ifdef NDEBUG 4890-#warning "libinput relies on assert(). #defining NDEBUG is not recommended" 4891-#endif 4892- 4893+//#ifdef NDEBUG 4894+//#warning "libinput relies on assert(). #defining NDEBUG is not recommended" 4895+//#endif 4896 4897 #include "libinput.h" 4898 4899@@ -57,6 +56,15 @@ 4900 #define DEFAULT_MOUSE_DPI 1000 4901 #define DEFAULT_TRACKPOINT_SENSITIVITY 128 4902 4903+ 4904+#ifdef HAVE_LIBINPUT_LOG_ENABLE 4905+void libinput_log_printf(const char* fmt, ...); 4906+uint64_t getMicrotime(); 4907+uint64_t getTranTime(struct input_event *event); 4908+#else 4909+#define libinput_log_printf(fmt, ...) 4910+#endif 4911+ 4912 #define trace(...) \ 4913 do { \ 4914 printf("%s() - \033[0;31m", __func__); \ 4915diff -Naur old/src/libinput-version.h new/src/libinput-version.h 4916--- old/src/libinput-version.h 1970-01-01 00:00:00.000000000 +0000 4917+++ new/src/libinput-version.h 2021-01-01 00:00:00.000000000 +0000 4918@@ -0,0 +1,32 @@ 4919+/* 4920+ * Copyright © 2013 Jonas Ådahl 4921+ * 4922+ * Permission is hereby granted, free of charge, to any person obtaining a 4923+ * copy of this software and associated documentation files (the "Software"), 4924+ * to deal in the Software without restriction, including without limitation 4925+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, 4926+ * and/or sell copies of the Software, and to permit persons to whom the 4927+ * Software is furnished to do so, subject to the following conditions: 4928+ * 4929+ * The above copyright notice and this permission notice (including the next 4930+ * paragraph) shall be included in all copies or substantial portions of the 4931+ * Software. 4932+ * 4933+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 4934+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 4935+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 4936+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 4937+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 4938+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 4939+ * DEALINGS IN THE SOFTWARE. 4940+ */ 4941+ 4942+#ifndef LIBINPUT_VERSION_H 4943+#define LIBINPUT_VERSION_H 4944+ 4945+#define LIBINPUT_VERSION_MAJOR //@LIBINPUT_VERSION_MAJOR@ 4946+#define LIBINPUT_VERSION_MINOR //@LIBINPUT_VERSION_MINOR@ 4947+#define LIBINPUT_VERSION_MICRO //@LIBINPUT_VERSION_MICRO@ 4948+#define LIBINPUT_VERSION "@LIBINPUT_VERSION@" 4949+ 4950+#endif 4951diff -Naur old/src/libinput.c new/src/libinput.c 4952--- old/src/libinput.c 2021-01-01 00:00:00.000000000 +0000 4953+++ new/src/libinput.c 2021-01-01 00:00:00.000000000 +0000 4954@@ -36,9 +36,11 @@ 4955 4956 #include "libinput.h" 4957 #include "libinput-private.h" 4958+#include "evdev-mt-touchpad.h" 4959 #include "evdev.h" 4960 #include "timer.h" 4961 #include "quirks.h" 4962+#include "evdev-joystick.h" 4963 4964 #define require_event_type(li_, type_, retval_, ...) \ 4965 if (type_ == LIBINPUT_EVENT_NONE) abort(); \ 4966@@ -83,9 +85,14 @@ 4967 CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED); 4968 CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED); 4969 CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY); 4970+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_TAP); 4971+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD); 4972+ CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 4973 CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION); 4974 CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE); 4975 CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON); 4976+ CASE_RETURN_STRING(LIBINPUT_EVENT_JOYSTICK_AXIS); 4977+ CASE_RETURN_STRING(LIBINPUT_EVENT_JOYSTICK_BUTTON); 4978 CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS); 4979 CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_SCROLL_WHEEL); 4980 CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_SCROLL_FINGER); 4981@@ -95,6 +102,9 @@ 4982 CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION); 4983 CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL); 4984 CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME); 4985+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCHPAD_DOWN); 4986+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCHPAD_UP); 4987+ CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCHPAD_MOTION); 4988 CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS); 4989 CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY); 4990 CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP); 4991@@ -192,6 +202,10 @@ 4992 int32_t slot; 4993 int32_t seat_slot; 4994 struct device_coords point; 4995+ struct device_coord_rect tool_rect; 4996+ int32_t pressure; 4997+ struct touch_axis axis; 4998+ int32_t tool_type; 4999 }; 5000 5001 struct libinput_event_gesture { 5002@@ -201,8 +215,10 @@ 5003 int cancelled; 5004 struct normalized_coords delta; 5005 struct normalized_coords delta_unaccel; 5006+ struct sloted_coords_info solt_touches; 5007 double scale; 5008 double angle; 5009+ struct device_coords coords[5]; 5010 }; 5011 5012 struct libinput_event_tablet_tool { 5013@@ -216,6 +232,7 @@ 5014 struct libinput_tablet_tool *tool; 5015 enum libinput_tablet_tool_proximity_state proximity_state; 5016 enum libinput_tablet_tool_tip_state tip_state; 5017+ int32_t mt_tool_type; 5018 }; 5019 5020 struct libinput_event_tablet_pad { 5021@@ -361,6 +378,7 @@ 5022 return event->device; 5023 } 5024 5025+ 5026 LIBINPUT_EXPORT struct libinput_event_pointer * 5027 libinput_event_get_pointer_event(struct libinput_event *event) 5028 { 5029@@ -373,7 +391,10 @@ 5030 LIBINPUT_EVENT_POINTER_SCROLL_WHEEL, 5031 LIBINPUT_EVENT_POINTER_SCROLL_FINGER, 5032 LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS, 5033- LIBINPUT_EVENT_POINTER_AXIS); 5034+ LIBINPUT_EVENT_POINTER_AXIS, 5035+ LIBINPUT_EVENT_POINTER_TAP, 5036+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD, 5037+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 5038 5039 return (struct libinput_event_pointer *) event; 5040 } 5041@@ -403,6 +424,18 @@ 5042 return (struct libinput_event_touch *) event; 5043 } 5044 5045+LIBINPUT_EXPORT struct libinput_event_touch * 5046+libinput_event_get_touchpad_event(struct libinput_event *event) 5047+{ 5048+ require_event_type(libinput_event_get_context(event), 5049+ event->type, 5050+ NULL, 5051+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5052+ LIBINPUT_EVENT_TOUCHPAD_UP, 5053+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5054+ return (struct libinput_event_touch *) event; 5055+} 5056+ 5057 LIBINPUT_EXPORT struct libinput_event_gesture * 5058 libinput_event_get_gesture_event(struct libinput_event *event) 5059 { 5060@@ -416,7 +449,10 @@ 5061 LIBINPUT_EVENT_GESTURE_PINCH_UPDATE, 5062 LIBINPUT_EVENT_GESTURE_PINCH_END, 5063 LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 5064- LIBINPUT_EVENT_GESTURE_HOLD_END); 5065+ LIBINPUT_EVENT_GESTURE_HOLD_END, 5066+ LIBINPUT_EVENT_POINTER_TAP, 5067+ LIBINPUT_EVENT_POINTER_BUTTON, 5068+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 5069 5070 return (struct libinput_event_gesture *) event; 5071 } 5072@@ -472,6 +508,19 @@ 5073 return (struct libinput_event_switch *) event; 5074 } 5075 5076+LIBINPUT_EXPORT int32_t 5077+libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event) 5078+{ 5079+ require_event_type(libinput_event_get_context(&(event->base)), 5080+ event->base.type, 5081+ 0, 5082+ LIBINPUT_EVENT_TABLET_TOOL_AXIS, 5083+ LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY, 5084+ LIBINPUT_EVENT_TABLET_TOOL_TIP, 5085+ LIBINPUT_EVENT_TABLET_TOOL_BUTTON); 5086+ return event->mt_tool_type; 5087+} 5088+ 5089 LIBINPUT_EXPORT uint32_t 5090 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event) 5091 { 5092@@ -557,18 +606,29 @@ 5093 LIBINPUT_EVENT_POINTER_SCROLL_WHEEL, 5094 LIBINPUT_EVENT_POINTER_SCROLL_FINGER, 5095 LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS, 5096- LIBINPUT_EVENT_POINTER_AXIS); 5097+ LIBINPUT_EVENT_POINTER_AXIS, 5098+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD); 5099 5100 return event->time; 5101 } 5102 5103+LIBINPUT_EXPORT uint64_t 5104+libinput_event_get_sensortime(struct libinput_event *event) 5105+{ 5106+ struct evdev_device *device = evdev_device(event->device); 5107+ int32_t seconds = device->sensor_timestamp.seconds; 5108+ int32_t microseconds = device->sensor_timestamp.microseconds; 5109+ return ((uint64_t)seconds * 1000 * 1000) + microseconds; 5110+} 5111+ 5112 LIBINPUT_EXPORT double 5113 libinput_event_pointer_get_dx(struct libinput_event_pointer *event) 5114 { 5115 require_event_type(libinput_event_get_context(&event->base), 5116 event->base.type, 5117 0, 5118- LIBINPUT_EVENT_POINTER_MOTION); 5119+ LIBINPUT_EVENT_POINTER_MOTION, 5120+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD); 5121 5122 return event->delta.x; 5123 } 5124@@ -579,7 +639,8 @@ 5125 require_event_type(libinput_event_get_context(&event->base), 5126 event->base.type, 5127 0, 5128- LIBINPUT_EVENT_POINTER_MOTION); 5129+ LIBINPUT_EVENT_POINTER_MOTION, 5130+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD); 5131 5132 return event->delta.y; 5133 } 5134@@ -591,7 +652,8 @@ 5135 require_event_type(libinput_event_get_context(&event->base), 5136 event->base.type, 5137 0, 5138- LIBINPUT_EVENT_POINTER_MOTION); 5139+ LIBINPUT_EVENT_POINTER_MOTION, 5140+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD); 5141 5142 return event->delta_raw.x; 5143 } 5144@@ -603,7 +665,8 @@ 5145 require_event_type(libinput_event_get_context(&event->base), 5146 event->base.type, 5147 0, 5148- LIBINPUT_EVENT_POINTER_MOTION); 5149+ LIBINPUT_EVENT_POINTER_MOTION, 5150+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD); 5151 5152 return event->delta_raw.y; 5153 } 5154@@ -670,7 +733,9 @@ 5155 require_event_type(libinput_event_get_context(&event->base), 5156 event->base.type, 5157 0, 5158- LIBINPUT_EVENT_POINTER_BUTTON); 5159+ LIBINPUT_EVENT_POINTER_BUTTON, 5160+ LIBINPUT_EVENT_POINTER_TAP, 5161+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 5162 5163 return event->button; 5164 } 5165@@ -681,7 +746,9 @@ 5166 require_event_type(libinput_event_get_context(&event->base), 5167 event->base.type, 5168 0, 5169- LIBINPUT_EVENT_POINTER_BUTTON); 5170+ LIBINPUT_EVENT_POINTER_BUTTON, 5171+ LIBINPUT_EVENT_POINTER_TAP, 5172+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 5173 5174 return event->state; 5175 } 5176@@ -693,11 +760,28 @@ 5177 require_event_type(libinput_event_get_context(&event->base), 5178 event->base.type, 5179 0, 5180- LIBINPUT_EVENT_POINTER_BUTTON); 5181+ LIBINPUT_EVENT_POINTER_BUTTON, 5182+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 5183 5184 return event->seat_button_count; 5185 } 5186 5187+LIBINPUT_EXPORT uint32_t 5188+libinput_event_pointer_get_finger_count( 5189+ struct libinput_event_pointer *event) 5190+{ 5191+ require_event_type(libinput_event_get_context(&event->base), 5192+ event->base.type, 5193+ 0, 5194+ LIBINPUT_EVENT_POINTER_BUTTON, 5195+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 5196+ 5197+ struct evdev_device *device = evdev_device(event->base.device); 5198+ struct evdev_dispatch *dispatch = device->dispatch; 5199+ struct tp_dispatch *tp = (struct tp_dispatch *)(dispatch); 5200+ 5201+ return tp->nfingers_down; 5202+} 5203 LIBINPUT_EXPORT int 5204 libinput_event_pointer_has_axis(struct libinput_event_pointer *event, 5205 enum libinput_pointer_axis axis) 5206@@ -929,6 +1013,20 @@ 5207 } 5208 5209 LIBINPUT_EXPORT double 5210+libinput_event_touch_get_y(struct libinput_event_touch *event) 5211+{ 5212+ struct evdev_device *device = evdev_device(event->base.device); 5213+ 5214+ require_event_type(libinput_event_get_context(&event->base), 5215+ event->base.type, 5216+ 0, 5217+ LIBINPUT_EVENT_TOUCH_DOWN, 5218+ LIBINPUT_EVENT_TOUCH_MOTION); 5219+ 5220+ return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y); 5221+} 5222+ 5223+LIBINPUT_EXPORT double 5224 libinput_event_touch_get_y_transformed(struct libinput_event_touch *event, 5225 uint32_t height) 5226 { 5227@@ -944,7 +1042,36 @@ 5228 } 5229 5230 LIBINPUT_EXPORT double 5231-libinput_event_touch_get_y(struct libinput_event_touch *event) 5232+libinput_event_touch_get_tool_x(struct libinput_event_touch *event) 5233+{ 5234+ struct evdev_device *device = evdev_device(event->base.device); 5235+ 5236+ require_event_type(libinput_event_get_context(&event->base), 5237+ event->base.type, 5238+ 0, 5239+ LIBINPUT_EVENT_TOUCH_DOWN, 5240+ LIBINPUT_EVENT_TOUCH_MOTION); 5241+ 5242+ return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.x); 5243+} 5244+ 5245+LIBINPUT_EXPORT double 5246+libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event, 5247+ uint32_t width) 5248+{ 5249+ struct evdev_device *device = evdev_device(event->base.device); 5250+ 5251+ require_event_type(libinput_event_get_context(&event->base), 5252+ event->base.type, 5253+ 0, 5254+ LIBINPUT_EVENT_TOUCH_DOWN, 5255+ LIBINPUT_EVENT_TOUCH_MOTION); 5256+ 5257+ return evdev_device_transform_x(device, event->tool_rect.x, width); 5258+} 5259+ 5260+LIBINPUT_EXPORT double 5261+libinput_event_touch_get_tool_y(struct libinput_event_touch *event) 5262 { 5263 struct evdev_device *device = evdev_device(event->base.device); 5264 5265@@ -954,9 +1081,329 @@ 5266 LIBINPUT_EVENT_TOUCH_DOWN, 5267 LIBINPUT_EVENT_TOUCH_MOTION); 5268 5269+ return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.y); 5270+} 5271+ 5272+LIBINPUT_EXPORT double 5273+libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event, 5274+ uint32_t height) 5275+{ 5276+ struct evdev_device *device = evdev_device(event->base.device); 5277+ 5278+ require_event_type(libinput_event_get_context(&event->base), 5279+ event->base.type, 5280+ 0, 5281+ LIBINPUT_EVENT_TOUCH_DOWN, 5282+ LIBINPUT_EVENT_TOUCH_MOTION); 5283+ 5284+ return evdev_device_transform_y(device, event->tool_rect.y, height); 5285+} 5286+ 5287+LIBINPUT_EXPORT double 5288+libinput_event_touch_get_tool_width(struct libinput_event_touch *event) 5289+{ 5290+ struct evdev_device *device = evdev_device(event->base.device); 5291+ 5292+ require_event_type(libinput_event_get_context(&event->base), 5293+ event->base.type, 5294+ 0, 5295+ LIBINPUT_EVENT_TOUCH_DOWN, 5296+ LIBINPUT_EVENT_TOUCH_MOTION); 5297+ 5298+ return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.w); 5299+} 5300+ 5301+LIBINPUT_EXPORT double 5302+libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event, 5303+ uint32_t width) 5304+{ 5305+ struct evdev_device *device = evdev_device(event->base.device); 5306+ 5307+ require_event_type(libinput_event_get_context(&event->base), 5308+ event->base.type, 5309+ 0, 5310+ LIBINPUT_EVENT_TOUCH_DOWN, 5311+ LIBINPUT_EVENT_TOUCH_MOTION); 5312+ 5313+ return evdev_device_transform_x(device, event->tool_rect.w, width); 5314+} 5315+ 5316+LIBINPUT_EXPORT double 5317+libinput_event_touch_get_tool_height(struct libinput_event_touch *event) 5318+{ 5319+ struct evdev_device *device = evdev_device(event->base.device); 5320+ 5321+ require_event_type(libinput_event_get_context(&event->base), 5322+ event->base.type, 5323+ 0, 5324+ LIBINPUT_EVENT_TOUCH_DOWN, 5325+ LIBINPUT_EVENT_TOUCH_MOTION); 5326+ 5327+ return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.h); 5328+} 5329+ 5330+LIBINPUT_EXPORT double 5331+libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event, 5332+ uint32_t height) 5333+{ 5334+ struct evdev_device *device = evdev_device(event->base.device); 5335+ 5336+ require_event_type(libinput_event_get_context(&event->base), 5337+ event->base.type, 5338+ 0, 5339+ LIBINPUT_EVENT_TOUCH_DOWN, 5340+ LIBINPUT_EVENT_TOUCH_MOTION); 5341+ 5342+ return evdev_device_transform_y(device, event->tool_rect.h, height); 5343+} 5344+ 5345+LIBINPUT_EXPORT uint32_t 5346+libinput_event_touchpad_get_time(struct libinput_event_touch *event) 5347+{ 5348+ require_event_type(libinput_event_get_context(&event->base), 5349+ event->base.type, 5350+ 0, 5351+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5352+ LIBINPUT_EVENT_TOUCHPAD_UP, 5353+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5354+ 5355+ return us2ms(event->time); 5356+} 5357+ 5358+LIBINPUT_EXPORT uint64_t 5359+libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event) 5360+{ 5361+ require_event_type(libinput_event_get_context(&event->base), 5362+ event->base.type, 5363+ 0, 5364+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5365+ LIBINPUT_EVENT_TOUCHPAD_UP, 5366+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5367+ 5368+ return event->time; 5369+} 5370+ 5371+LIBINPUT_EXPORT int32_t 5372+libinput_event_touchpad_get_slot(struct libinput_event_touch *event) 5373+{ 5374+ require_event_type(libinput_event_get_context(&event->base), 5375+ event->base.type, 5376+ 0, 5377+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5378+ LIBINPUT_EVENT_TOUCHPAD_UP, 5379+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5380+ 5381+ return event->slot; 5382+} 5383+ 5384+LIBINPUT_EXPORT int32_t 5385+libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event) 5386+{ 5387+ require_event_type(libinput_event_get_context(&event->base), 5388+ event->base.type, 5389+ 0, 5390+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5391+ LIBINPUT_EVENT_TOUCHPAD_UP, 5392+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5393+ 5394+ return event->seat_slot; 5395+} 5396+ 5397+LIBINPUT_EXPORT double 5398+libinput_event_touchpad_get_x(struct libinput_event_touch *event) 5399+{ 5400+ struct evdev_device *device = evdev_device(event->base.device); 5401+ 5402+ require_event_type(libinput_event_get_context(&event->base), 5403+ event->base.type, 5404+ 0, 5405+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5406+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5407+ 5408+ return evdev_convert_to_mm(device->abs.absinfo_x, event->point.x); 5409+} 5410+ 5411+LIBINPUT_EXPORT double 5412+libinput_event_touchpad_get_y(struct libinput_event_touch *event) 5413+{ 5414+ struct evdev_device *device = evdev_device(event->base.device); 5415+ 5416+ require_event_type(libinput_event_get_context(&event->base), 5417+ event->base.type, 5418+ 0, 5419+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5420+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5421+ 5422 return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y); 5423 } 5424 5425+LIBINPUT_EXPORT double 5426+libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event) 5427+{ 5428+ struct evdev_device *device = evdev_device(event->base.device); 5429+ 5430+ require_event_type(libinput_event_get_context(&event->base), 5431+ event->base.type, 5432+ 0, 5433+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5434+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5435+ 5436+ return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.x); 5437+} 5438+ 5439+LIBINPUT_EXPORT double 5440+libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event) 5441+{ 5442+ struct evdev_device *device = evdev_device(event->base.device); 5443+ 5444+ require_event_type(libinput_event_get_context(&event->base), 5445+ event->base.type, 5446+ 0, 5447+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5448+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5449+ 5450+ return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.y); 5451+} 5452+ 5453+LIBINPUT_EXPORT double 5454+libinput_event_touchpad_get_tool_width(struct libinput_event_touch *event) 5455+{ 5456+ struct evdev_device *device = evdev_device(event->base.device); 5457+ 5458+ require_event_type(libinput_event_get_context(&event->base), 5459+ event->base.type, 5460+ 0, 5461+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5462+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5463+ 5464+ return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.w); 5465+} 5466+ 5467+LIBINPUT_EXPORT double 5468+libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event) 5469+{ 5470+ struct evdev_device *device = evdev_device(event->base.device); 5471+ 5472+ require_event_type(libinput_event_get_context(&event->base), 5473+ event->base.type, 5474+ 0, 5475+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5476+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5477+ 5478+ return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.h); 5479+} 5480+ 5481+LIBINPUT_EXPORT double 5482+libinput_event_touchpad_get_pressure(struct libinput_event_touch *event) 5483+{ 5484+ require_event_type(libinput_event_get_context(&event->base), 5485+ event->base.type, 5486+ 0, 5487+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5488+ LIBINPUT_EVENT_TOUCHPAD_UP, 5489+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5490+ 5491+ struct libinput_device* device = libinput_event_get_device(&event->base); 5492+ if (device == NULL) { 5493+ return 0.0; 5494+ } 5495+ struct evdev_device* evDevice = evdev_device(device); 5496+ if (evDevice == NULL) { 5497+ return 0.0; 5498+ } 5499+ double range = evDevice->pressureMax; 5500+ if (range == 0.0) { 5501+ return 0.0; 5502+ } 5503+ double value = event->pressure / range; 5504+ return max(0.0, value); 5505+} 5506+ 5507+LIBINPUT_EXPORT int32_t 5508+libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event) 5509+{ 5510+ require_event_type(libinput_event_get_context(&event->base), 5511+ event->base.type, 5512+ 0, 5513+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5514+ LIBINPUT_EVENT_TOUCHPAD_UP, 5515+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5516+ struct libinput_device* device = libinput_event_get_device(&event->base); 5517+ if (device == NULL) { 5518+ libinput_log_printf("device is nullptr\n"); 5519+ return 0; 5520+ } 5521+ struct evdev_device* evDevice = evdev_device(device); 5522+ if (evDevice == NULL) { 5523+ libinput_log_printf("evdev_device is nullptr\n"); 5524+ return 0; 5525+ } 5526+ const struct input_absinfo* absInfo = libevdev_get_abs_info(evDevice->evdev, ABS_MT_TOUCH_MAJOR); 5527+ if (absInfo == NULL) { 5528+ libinput_log_printf("ABS_MT_TOUCH_MAJOR absInfo is nullptr\n"); 5529+ return 0; 5530+ } 5531+ if (event->axis.major > absInfo->maximum || event->axis.major < 0) { 5532+ libinput_log_printf(" major = %d > absInfo->maximum\n", event->axis.major); 5533+ return 0; 5534+ } 5535+ return event->axis.major; 5536+} 5537+ 5538+LIBINPUT_EXPORT int32_t 5539+libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event) 5540+{ 5541+ require_event_type(libinput_event_get_context(&event->base), 5542+ event->base.type, 5543+ 0, 5544+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5545+ LIBINPUT_EVENT_TOUCHPAD_UP, 5546+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5547+ 5548+ struct libinput_device* device = libinput_event_get_device(&event->base); 5549+ if (device == NULL) { 5550+ libinput_log_printf("device is nullptr\n"); 5551+ return 0; 5552+ } 5553+ struct evdev_device* evDevice = evdev_device(device); 5554+ if (evDevice == NULL) { 5555+ libinput_log_printf("evdev_device is nullptr\n"); 5556+ return 0; 5557+ } 5558+ const struct input_absinfo* absInfo = libevdev_get_abs_info(evDevice->evdev, ABS_MT_TOUCH_MINOR); 5559+ if (absInfo == NULL) { 5560+ libinput_log_printf("ABS_MT_TOUCH_MAJOR absInfo is nullptr\n"); 5561+ return 0; 5562+ } 5563+ if (event->axis.minor > absInfo->maximum || event->axis.minor < 0) { 5564+ libinput_log_printf(" major = %d > absInfo->maximum\n", event->axis.minor); 5565+ return 0; 5566+ } 5567+ return event->axis.minor; 5568+} 5569+ 5570+LIBINPUT_EXPORT int32_t 5571+libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event) 5572+{ 5573+ require_event_type(libinput_event_get_context(&event->base), 5574+ event->base.type, 5575+ 0, 5576+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5577+ LIBINPUT_EVENT_TOUCHPAD_UP, 5578+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 5579+ 5580+ return event->tool_type; 5581+} 5582+ 5583+LIBINPUT_EXPORT int32_t 5584+libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType) 5585+{ 5586+ if (device == NULL) { 5587+ return -1; 5588+ } 5589+ return evdev_device_touchpad_btn_tool_type_down((struct evdev_device *)device, btnToolType); 5590+} 5591+ 5592 LIBINPUT_EXPORT uint32_t 5593 libinput_event_gesture_get_time(struct libinput_event_gesture *event) 5594 { 5595@@ -1117,6 +1564,44 @@ 5596 } 5597 5598 LIBINPUT_EXPORT int 5599+libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx) 5600+{ 5601+ require_event_type(libinput_event_get_context(&event->base), 5602+ event->base.type, 5603+ 0, 5604+ LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 5605+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, 5606+ LIBINPUT_EVENT_GESTURE_SWIPE_END); 5607+ 5608+ return event->coords[idx].x; 5609+} 5610+ 5611+LIBINPUT_EXPORT int 5612+libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx) 5613+{ 5614+ require_event_type(libinput_event_get_context(&event->base), 5615+ event->base.type, 5616+ 0, 5617+ LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 5618+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, 5619+ LIBINPUT_EVENT_GESTURE_SWIPE_END); 5620+ 5621+ return event->coords[idx].y; 5622+} 5623+ 5624+LIBINPUT_EXPORT struct sloted_coords_info * 5625+libinput_event_gesture_get_solt_touches( 5626+ struct libinput_event_gesture *event) 5627+{ 5628+ require_event_type(libinput_event_get_context(&event->base), 5629+ event->base.type, 5630+ NULL, 5631+ LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE); 5632+ 5633+ return &event->solt_touches; 5634+} 5635+ 5636+LIBINPUT_EXPORT int 5637 libinput_event_tablet_tool_x_has_changed( 5638 struct libinput_event_tablet_tool *event) 5639 { 5640@@ -1133,6 +1618,24 @@ 5641 } 5642 5643 LIBINPUT_EXPORT int 5644+libinput_has_event_led_type(struct libinput_device *device) 5645+{ 5646+ return evdev_has_event_type((struct evdev_device *)device, EV_LED); 5647+} 5648+ 5649+LIBINPUT_EXPORT int 5650+libinput_get_funckey_state(struct libinput_device *device, unsigned int code) 5651+{ 5652+ return evdev_get_event_value((struct evdev_device *)device, EV_LED, code); 5653+} 5654+ 5655+LIBINPUT_EXPORT int 5656+libinput_set_led_state(struct libinput_device *device, unsigned int code, unsigned int state) 5657+{ 5658+ return evdev_kernel_set_led_value((struct evdev_device *)device, code, state); 5659+} 5660+ 5661+LIBINPUT_EXPORT int 5662 libinput_event_tablet_tool_y_has_changed( 5663 struct libinput_event_tablet_tool *event) 5664 { 5665@@ -1891,11 +2394,8 @@ 5666 /* If we fail, we'll fail next time too */ 5667 libinput->quirks_initialized = true; 5668 5669- data_path = getenv("LIBINPUT_QUIRKS_DIR"); 5670- if (!data_path) { 5671- data_path = LIBINPUT_QUIRKS_DIR; 5672- override_file = LIBINPUT_QUIRKS_OVERRIDE_FILE; 5673- } 5674+ data_path = (char *)LIBINPUT_QUIRKS_DIR; 5675+ override_file = (char *)LIBINPUT_QUIRKS_OVERRIDE_FILE; 5676 5677 quirks = quirks_init_subsystem(data_path, 5678 override_file, 5679@@ -2395,6 +2895,9 @@ 5680 case LIBINPUT_DEVICE_CAP_SWITCH: 5681 capability = "CAP_SWITCH"; 5682 break; 5683+ case LIBINPUT_DEVICE_CAP_JOYSTICK: 5684+ capability = "CAP_JOYSTICK"; 5685+ break; 5686 } 5687 5688 log_bug_libinput(device->seat->libinput, 5689@@ -2458,6 +2961,30 @@ 5690 } 5691 5692 void 5693+touchpad_pointer_notify_motion(struct libinput_device *device, 5694+ uint64_t time, 5695+ const struct normalized_coords *delta, 5696+ const struct device_float_coords *raw) 5697+{ 5698+ struct libinput_event_pointer *motion_event; 5699+ 5700+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) 5701+ return; 5702+ 5703+ motion_event = zalloc(sizeof *motion_event); 5704+ 5705+ *motion_event = (struct libinput_event_pointer) { 5706+ .time = time, 5707+ .delta = *delta, 5708+ .delta_raw = *raw, 5709+ }; 5710+ 5711+ post_device_event(device, time, 5712+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD, 5713+ &motion_event->base); 5714+} 5715+ 5716+void 5717 pointer_notify_motion_absolute(struct libinput_device *device, 5718 uint64_t time, 5719 const struct device_coords *point) 5720@@ -2510,6 +3037,66 @@ 5721 } 5722 5723 void 5724+pointer_notify_button_touchpad(struct libinput_device *device, 5725+ uint64_t time, 5726+ int32_t button, 5727+ enum libinput_button_state state) 5728+{ 5729+ struct libinput_event_pointer *button_event; 5730+ int32_t seat_button_count; 5731+ 5732+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) 5733+ return; 5734+ 5735+ button_event = zalloc(sizeof *button_event); 5736+ 5737+ seat_button_count = update_seat_button_count(device->seat, 5738+ button, 5739+ state); 5740+ 5741+ *button_event = (struct libinput_event_pointer) { 5742+ .time = time, 5743+ .button = button, 5744+ .state = state, 5745+ .seat_button_count = seat_button_count, 5746+ }; 5747+ 5748+ post_device_event(device, time, 5749+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD, 5750+ &button_event->base); 5751+} 5752+ 5753+void 5754+pointer_notify_tap(struct libinput_device *device, 5755+ uint64_t time, 5756+ int32_t button, 5757+ enum libinput_button_state state) 5758+{ 5759+ struct libinput_event_pointer *button_event; 5760+ int32_t seat_button_count; 5761+ 5762+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER)) 5763+ return; 5764+ 5765+ button_event = zalloc(sizeof *button_event); 5766+ 5767+ seat_button_count = update_seat_button_count(device->seat, 5768+ button, 5769+ state); 5770+ 5771+ *button_event = (struct libinput_event_pointer) { 5772+ .time = time, 5773+ .button = button, 5774+ .state = state, 5775+ .seat_button_count = seat_button_count, 5776+ }; 5777+ 5778+ post_device_event(device, time, 5779+ LIBINPUT_EVENT_POINTER_TAP, 5780+ &button_event->base); 5781+} 5782+ 5783+void 5784 pointer_notify_axis_finger(struct libinput_device *device, 5785 uint64_t time, 5786 uint32_t axes, 5787@@ -2642,7 +3229,11 @@ 5788 uint64_t time, 5789 int32_t slot, 5790 int32_t seat_slot, 5791- const struct device_coords *point) 5792+ int32_t pressure, 5793+ const struct touch_axis *axis, 5794+ const struct device_coords *point, 5795+ int32_t tool_type, 5796+ const struct device_coord_rect *tool_rect) 5797 { 5798 struct libinput_event_touch *touch_event; 5799 5800@@ -2656,6 +3247,10 @@ 5801 .slot = slot, 5802 .seat_slot = seat_slot, 5803 .point = *point, 5804+ .tool_rect = *tool_rect, 5805+ .pressure = pressure, 5806+ .axis = *axis, 5807+ .tool_type = tool_type, 5808 }; 5809 5810 post_device_event(device, time, 5811@@ -2668,7 +3263,11 @@ 5812 uint64_t time, 5813 int32_t slot, 5814 int32_t seat_slot, 5815- const struct device_coords *point) 5816+ int32_t pressure, 5817+ const struct touch_axis *axis, 5818+ const struct device_coords *point, 5819+ int32_t tool_type, 5820+ const struct device_coord_rect *tool_rect) 5821 { 5822 struct libinput_event_touch *touch_event; 5823 5824@@ -2682,6 +3281,10 @@ 5825 .slot = slot, 5826 .seat_slot = seat_slot, 5827 .point = *point, 5828+ .tool_rect = *tool_rect, 5829+ .pressure = pressure, 5830+ .axis = *axis, 5831+ .tool_type = tool_type, 5832 }; 5833 5834 post_device_event(device, time, 5835@@ -2693,7 +3296,8 @@ 5836 touch_notify_touch_up(struct libinput_device *device, 5837 uint64_t time, 5838 int32_t slot, 5839- int32_t seat_slot) 5840+ int32_t seat_slot, 5841+ int32_t tool_type) 5842 { 5843 struct libinput_event_touch *touch_event; 5844 5845@@ -2706,6 +3310,7 @@ 5846 .time = time, 5847 .slot = slot, 5848 .seat_slot = seat_slot, 5849+ .tool_type = tool_type, 5850 }; 5851 5852 post_device_event(device, time, 5853@@ -2758,6 +3363,90 @@ 5854 } 5855 5856 void 5857+touchpad_notify_touch_down(struct libinput_device *device, 5858+ uint64_t time, 5859+ int32_t slot, 5860+ int32_t seat_slot, 5861+ int32_t pressure, 5862+ int32_t tool_type, 5863+ struct touch_axis axis, 5864+ const struct device_coords *point, 5865+ const struct device_coord_rect *tool_rect) 5866+{ 5867+ struct libinput_event_touch *touch_event; 5868+ touch_event = zalloc(sizeof *touch_event); 5869+ 5870+ *touch_event = (struct libinput_event_touch) { 5871+ .time = time, 5872+ .slot = slot, 5873+ .seat_slot = seat_slot, 5874+ .point = *point, 5875+ .tool_rect = *tool_rect, 5876+ .pressure = pressure, 5877+ .axis = axis, 5878+ .tool_type = tool_type, 5879+ }; 5880+ 5881+ post_device_event(device, time, 5882+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 5883+ &touch_event->base); 5884+} 5885+ 5886+void 5887+touchpad_notify_touch_motion(struct libinput_device *device, 5888+ uint64_t time, 5889+ int32_t slot, 5890+ int32_t seat_slot, 5891+ int32_t pressure, 5892+ int32_t tool_type, 5893+ struct touch_axis axis, 5894+ const struct device_coords *point, 5895+ const struct device_coord_rect *tool_rect) 5896+{ 5897+ struct libinput_event_touch *touch_event; 5898+ touch_event = zalloc(sizeof *touch_event); 5899+ 5900+ *touch_event = (struct libinput_event_touch) { 5901+ .time = time, 5902+ .slot = slot, 5903+ .seat_slot = seat_slot, 5904+ .point = *point, 5905+ .tool_rect = *tool_rect, 5906+ .axis = axis, 5907+ .pressure = pressure, 5908+ .tool_type = tool_type, 5909+ }; 5910+ 5911+ post_device_event(device, time, 5912+ LIBINPUT_EVENT_TOUCHPAD_MOTION, 5913+ &touch_event->base); 5914+} 5915+ 5916+void 5917+touchpad_notify_touch_up(struct libinput_device *device, 5918+ uint64_t time, 5919+ int32_t slot, 5920+ int32_t seat_slot, 5921+ int32_t tool_type, 5922+ struct touch_axis axis) 5923+{ 5924+ struct libinput_event_touch *touch_event; 5925+ touch_event = zalloc(sizeof *touch_event); 5926+ 5927+ *touch_event = (struct libinput_event_touch) { 5928+ .time = time, 5929+ .slot = slot, 5930+ .seat_slot = seat_slot, 5931+ .axis = axis, 5932+ .tool_type = tool_type, 5933+ }; 5934+ 5935+ post_device_event(device, time, 5936+ LIBINPUT_EVENT_TOUCHPAD_UP, 5937+ &touch_event->base); 5938+} 5939+ 5940+void 5941 tablet_notify_axis(struct libinput_device *device, 5942 uint64_t time, 5943 struct libinput_tablet_tool *tool, 5944@@ -2775,6 +3464,7 @@ 5945 .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, 5946 .tip_state = tip_state, 5947 .axes = *axes, 5948+ .mt_tool_type = tool->pressure.mt_tool_type, 5949 }; 5950 5951 memcpy(axis_event->changed_axes, 5952@@ -2805,6 +3495,7 @@ 5953 .tip_state = LIBINPUT_TABLET_TOOL_TIP_UP, 5954 .proximity_state = proximity_state, 5955 .axes = *axes, 5956+ .mt_tool_type = tool->pressure.mt_tool_type, 5957 }; 5958 memcpy(proximity_event->changed_axes, 5959 changed_axes, 5960@@ -2834,6 +3525,7 @@ 5961 .tip_state = tip_state, 5962 .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, 5963 .axes = *axes, 5964+ .mt_tool_type = tool->pressure.mt_tool_type, 5965 }; 5966 memcpy(tip_event->changed_axes, 5967 changed_axes, 5968@@ -2872,6 +3564,7 @@ 5969 .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, 5970 .tip_state = tip_state, 5971 .axes = *axes, 5972+ .mt_tool_type = tool->pressure.mt_tool_type, 5973 }; 5974 5975 post_device_event(device, 5976@@ -2998,6 +3691,7 @@ 5977 bool cancelled, 5978 const struct normalized_coords *delta, 5979 const struct normalized_coords *unaccel, 5980+ const struct sloted_coords_info *solt_touches, 5981 double scale, 5982 double angle) 5983 { 5984@@ -3018,6 +3712,48 @@ 5985 .angle = angle, 5986 }; 5987 5988+ if (solt_touches != NULL) { 5989+ gesture_event->solt_touches = *solt_touches; 5990+ } else { 5991+ memset(&gesture_event->solt_touches, 0, sizeof(struct sloted_coords_info)); 5992+ } 5993+ 5994+ post_device_event(device, time, type, 5995+ &gesture_event->base); 5996+} 5997+ 5998+static void 5999+gesture_notify_private(struct libinput_device *device, 6000+ uint64_t time, 6001+ enum libinput_event_type type, 6002+ int finger_count, 6003+ int cancelled, 6004+ const struct normalized_coords *delta, 6005+ const struct normalized_coords *unaccel, 6006+ double scale, 6007+ double angle, 6008+ struct device_coords *coords, 6009+ int coordsLen) 6010+{ 6011+ struct libinput_event_gesture *gesture_event; 6012+ 6013+ if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_GESTURE)) 6014+ return; 6015+ 6016+ gesture_event = zalloc(sizeof *gesture_event); 6017+ 6018+ *gesture_event = (struct libinput_event_gesture) { 6019+ .time = time, 6020+ .finger_count = finger_count, 6021+ .cancelled = cancelled, 6022+ .delta = *delta, 6023+ .delta_unaccel = *unaccel, 6024+ .scale = scale, 6025+ .angle = angle, 6026+ }; 6027+ 6028+ memcpy(gesture_event->coords, coords, coordsLen * sizeof(struct device_coords)); 6029+ 6030 post_device_event(device, time, type, 6031 &gesture_event->base); 6032 } 6033@@ -3028,13 +3764,28 @@ 6034 enum libinput_event_type type, 6035 int finger_count, 6036 const struct normalized_coords *delta, 6037- const struct normalized_coords *unaccel) 6038+ const struct normalized_coords *unaccel, 6039+ const struct sloted_coords_info *solt_touches) 6040 { 6041- gesture_notify(device, time, type, finger_count, 0, delta, unaccel, 6042+ gesture_notify(device, time, type, finger_count, 0, delta, unaccel, solt_touches, 6043 0.0, 0.0); 6044 } 6045 6046 void 6047+gesture_notify_swipe_private(struct libinput_device *device, 6048+ uint64_t time, 6049+ enum libinput_event_type type, 6050+ int finger_count, 6051+ const struct normalized_coords *delta, 6052+ const struct normalized_coords *unaccel, 6053+ struct device_coords *coords, 6054+ int coordsLen) 6055+{ 6056+ gesture_notify_private(device, time, type, finger_count, 0, delta, unaccel, 6057+ 0.0, 0.0, coords, coordsLen); 6058+} 6059+ 6060+void 6061 gesture_notify_swipe_end(struct libinput_device *device, 6062 uint64_t time, 6063 int finger_count, 6064@@ -3043,7 +3794,7 @@ 6065 const struct normalized_coords zero = { 0.0, 0.0 }; 6066 6067 gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_SWIPE_END, 6068- finger_count, cancelled, &zero, &zero, 0.0, 0.0); 6069+ finger_count, cancelled, &zero, &zero, NULL, 0.0, 0.0); 6070 } 6071 6072 void 6073@@ -3057,7 +3808,7 @@ 6074 double angle) 6075 { 6076 gesture_notify(device, time, type, finger_count, 0, 6077- delta, unaccel, scale, angle); 6078+ delta, unaccel, NULL, scale, angle); 6079 } 6080 6081 void 6082@@ -3070,7 +3821,7 @@ 6083 const struct normalized_coords zero = { 0.0, 0.0 }; 6084 6085 gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_PINCH_END, 6086- finger_count, cancelled, &zero, &zero, scale, 0.0); 6087+ finger_count, cancelled, &zero, &zero, NULL, scale, 0.0); 6088 } 6089 6090 void 6091@@ -3081,7 +3832,7 @@ 6092 const struct normalized_coords zero = { 0.0, 0.0 }; 6093 6094 gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 6095- finger_count, 0, &zero, &zero, 0.0, 0.0); 6096+ finger_count, 0, &zero, &zero, NULL, 0.0, 0.0); 6097 } 6098 6099 void 6100@@ -3093,7 +3844,7 @@ 6101 const struct normalized_coords zero = { 0.0, 0.0 }; 6102 6103 gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_HOLD_END, 6104- finger_count, cancelled, &zero, &zero, 0, 0.0); 6105+ finger_count, cancelled, &zero, &zero, NULL, 0, 0.0); 6106 } 6107 6108 void 6109@@ -3126,6 +3877,46 @@ 6110 #endif 6111 } 6112 6113+void 6114+joysticks_notify_axis(struct libinput_device *device, 6115+ uint64_t time, 6116+ uint32_t axes, 6117+ const struct joystick_axis_abs_infos *axis_abs) 6118+{ 6119+ struct libinput_event_joystick_axis* joystick_axis_event; 6120+ 6121+ joystick_axis_event = zalloc(sizeof * joystick_axis_event); 6122+ 6123+ *joystick_axis_event = (struct libinput_event_joystick_axis){ 6124+ .type = EV_ABS, 6125+ .time = time, 6126+ .axis_value_mask = axes, 6127+ .abs_throttle = axis_abs->abs_throttle, 6128+ .abs_hat0x = axis_abs->abs_hat0x, 6129+ .abs_hat0y = axis_abs->abs_hat0y, 6130+ .abs_x = axis_abs->abs_x, 6131+ .abs_y = axis_abs->abs_y, 6132+ .abs_z = axis_abs->abs_z, 6133+ .abs_rx = axis_abs->abs_rx, 6134+ .abs_ry = axis_abs->abs_ry, 6135+ .abs_rz = axis_abs->abs_rz, 6136+ .abs_gas = axis_abs->abs_gas, 6137+ .abs_brake = axis_abs->abs_brake, 6138+ }; 6139+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_x.code, axis_abs->abs_x.value); 6140+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_y.code, axis_abs->abs_y.value); 6141+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_z.code, axis_abs->abs_z.value); 6142+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_rz.code, axis_abs->abs_rz.value); 6143+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_gas.code, axis_abs->abs_gas.value); 6144+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_brake.code, axis_abs->abs_brake.value); 6145+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_hat0x.code, axis_abs->abs_hat0x.value); 6146+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_hat0y.code, axis_abs->abs_hat0y.value); 6147+ libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_throttle.code, axis_abs->abs_throttle.value); 6148+ post_device_event(device, time, 6149+ LIBINPUT_EVENT_JOYSTICK_AXIS, 6150+ &joystick_axis_event->base); 6151+} 6152+ 6153 static void 6154 libinput_post_event(struct libinput *libinput, 6155 struct libinput_event *event) 6156@@ -3179,6 +3970,96 @@ 6157 libinput->events_in = (libinput->events_in + 1) % libinput->events_len; 6158 } 6159 6160+ 6161+LIBINPUT_EXPORT void 6162+libinput_post_handle_event(struct libinput* libinput, struct libinput_event* event) 6163+{ 6164+ libinput_post_event(libinput, event); 6165+} 6166+ 6167+LIBINPUT_EXPORT struct libinput_event_joystick_button* 6168+libinput_event_get_joystick_button_event(struct libinput_event* event) 6169+{ 6170+ require_event_type(libinput_event_get_context(event), 6171+ event->type, 6172+ NULL, 6173+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6174+ 6175+ return (struct libinput_event_joystick_button*)event; 6176+} 6177+ 6178+LIBINPUT_EXPORT struct libinput_event_joystick_axis* 6179+libinput_event_get_joystick_axis_event(struct libinput_event* event) 6180+{ 6181+ require_event_type(libinput_event_get_context(event), 6182+ event->type, 6183+ NULL, 6184+ LIBINPUT_EVENT_JOYSTICK_AXIS); 6185+ 6186+ return (struct libinput_event_joystick_axis*)event; 6187+} 6188+ 6189+/** 6190+ * @brief 获取joystick指定轴的数据是否变化 6191+*/ 6192+int32_t libinput_event_get_joystick_axis_value_is_changed(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis) 6193+{ 6194+ if (event == NULL) { 6195+ return 0; 6196+ } 6197+ 6198+ return (event->axis_value_mask & (uint32_t)axis); 6199+} 6200+ 6201+/** 6202+ * @brief 获取轴事件的时间 6203+ */ 6204+uint64_t 6205+libinput_event_get_joystick_axis_time(struct libinput_event_joystick_axis *event) 6206+{ 6207+ if (event == NULL) { 6208+ return 0; 6209+ } 6210+ 6211+ return event->time; 6212+} 6213+ 6214+/** 6215+ * @brief 获取joystick指定轴的abs信息 6216+*/ 6217+struct libinput_event_joystick_axis_abs_info * 6218+libinput_event_get_joystick_axis_abs_info(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis) 6219+{ 6220+ switch (axis) { 6221+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X: 6222+ return &event->abs_x; 6223+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y: 6224+ return &event->abs_y; 6225+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z: 6226+ return &event->abs_z; 6227+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX: 6228+ return &event->abs_rx; 6229+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY: 6230+ return &event->abs_ry; 6231+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ: 6232+ return &event->abs_rz; 6233+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE: 6234+ return &event->abs_throttle; 6235+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X: 6236+ return &event->abs_hat0x; 6237+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y: 6238+ return &event->abs_hat0y; 6239+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS: 6240+ return &event->abs_gas; 6241+ case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE: 6242+ return &event->abs_brake; 6243+ default: 6244+ break; 6245+ } 6246+ 6247+ return NULL; 6248+} 6249+ 6250 LIBINPUT_EXPORT struct libinput_event * 6251 libinput_get_event(struct libinput *libinput) 6252 { 6253@@ -3262,12 +4143,169 @@ 6254 return evdev_device_get_sysname((struct evdev_device *) device); 6255 } 6256 6257+LIBINPUT_EXPORT const char* 6258+libinput_device_get_phys(struct libinput_device* device) 6259+{ 6260+ struct libevdev* evdev = ((struct evdev_device*)device)->evdev; 6261+ if (evdev == NULL) { 6262+ return NULL; 6263+ } 6264+ return libevdev_get_phys(evdev); 6265+} 6266+ 6267+LIBINPUT_EXPORT const char* 6268+libinput_device_get_uniq(struct libinput_device* device) 6269+{ 6270+ struct libevdev* evdev = ((struct evdev_device*)device)->evdev; 6271+ if (evdev == NULL) { 6272+ return NULL; 6273+ } 6274+ return libevdev_get_uniq(evdev); 6275+} 6276+ 6277 LIBINPUT_EXPORT const char * 6278 libinput_device_get_name(struct libinput_device *device) 6279 { 6280 return evdev_device_get_name((struct evdev_device *) device); 6281 } 6282 6283+LIBINPUT_EXPORT enum evdev_device_udev_tags 6284+libinput_device_get_tags(struct libinput_device* device) 6285+{ 6286+ if(device == NULL) 6287+ { 6288+ return EVDEV_UDEV_TAG_INPUT; 6289+ } 6290+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6291+ enum evdev_device_udev_tags udev_tags; 6292+ udev_tags = evdev_device_get_udev_device_tags(evdevDevice); 6293+ return udev_tags; 6294+} 6295+ 6296+LIBINPUT_EXPORT int32_t 6297+libinput_device_has_key(struct libinput_device* device, int32_t keyCode) 6298+{ 6299+ if(device == NULL) 6300+ { 6301+ return EVDEV_UDEV_TAG_INPUT; 6302+ } 6303+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6304+ if (!libevdev_has_event_type(evdevDevice->evdev, EV_KEY)) { 6305+ return 0; 6306+ } 6307+ if (libevdev_has_event_code(evdevDevice->evdev, EV_KEY, keyCode)) { 6308+ return 1; 6309+ } 6310+ return 0; 6311+} 6312+ 6313+LIBINPUT_EXPORT int32_t 6314+libinput_device_get_axis_min(struct libinput_device* device, int32_t code) 6315+{ 6316+ if(device == NULL) 6317+ { 6318+ return -1; 6319+ } 6320+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6321+ if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) { 6322+ return -1; 6323+ } 6324+ const struct input_absinfo *absinfo; 6325+ if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) { 6326+ absinfo = libevdev_get_abs_info(evdevDevice->evdev, code); 6327+ return absinfo->minimum; 6328+ } 6329+ return -1; 6330+} 6331+ 6332+LIBINPUT_EXPORT int32_t 6333+libinput_device_get_axis_max(struct libinput_device* device, int32_t code) 6334+{ 6335+ if(device == NULL) 6336+ { 6337+ return -1; 6338+ } 6339+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6340+ if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) { 6341+ return -1; 6342+ } 6343+ const struct input_absinfo *absinfo; 6344+ if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) { 6345+ absinfo = libevdev_get_abs_info(evdevDevice->evdev, code); 6346+ return absinfo->maximum; 6347+ } 6348+ return -1; 6349+} 6350+ 6351+LIBINPUT_EXPORT int32_t 6352+libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code) 6353+{ 6354+ if(device == NULL) 6355+ { 6356+ return -1; 6357+ } 6358+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6359+ if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) { 6360+ return -1; 6361+ } 6362+ const struct input_absinfo *absinfo; 6363+ if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) { 6364+ absinfo = libevdev_get_abs_info(evdevDevice->evdev, code); 6365+ return absinfo->fuzz; 6366+ } 6367+ return -1; 6368+} 6369+ 6370+LIBINPUT_EXPORT int32_t 6371+libinput_device_get_axis_flat(struct libinput_device* device, int32_t code) 6372+{ 6373+ if(device == NULL) 6374+ { 6375+ return -1; 6376+ } 6377+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6378+ if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) { 6379+ return -1; 6380+ } 6381+ const struct input_absinfo *absinfo; 6382+ if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) { 6383+ absinfo = libevdev_get_abs_info(evdevDevice->evdev, code); 6384+ return absinfo->flat; 6385+ } 6386+ return -1; 6387+} 6388+ 6389+LIBINPUT_EXPORT int32_t 6390+libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code) 6391+{ 6392+ if(device == NULL) 6393+ { 6394+ return -1; 6395+ } 6396+ struct evdev_device* evdevDevice = (struct evdev_device*)device; 6397+ if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) { 6398+ return -1; 6399+ } 6400+ const struct input_absinfo *absinfo; 6401+ if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) { 6402+ absinfo = libevdev_get_abs_info(evdevDevice->evdev, code); 6403+ return absinfo->resolution; 6404+ } 6405+ return -1; 6406+} 6407+ 6408+LIBINPUT_EXPORT unsigned int 6409+libinput_device_get_id_bustype(struct libinput_device* device) 6410+{ 6411+ return evdev_device_get_id_bustype((struct evdev_device *) device); 6412+} 6413+ 6414+LIBINPUT_EXPORT unsigned int 6415+libinput_device_get_id_version(struct libinput_device* device) 6416+{ 6417+ return evdev_device_get_id_version((struct evdev_device *) device); 6418+} 6419+ 6420 LIBINPUT_EXPORT unsigned int 6421 libinput_device_get_id_product(struct libinput_device *device) 6422 { 6423@@ -3355,6 +4393,15 @@ 6424 } 6425 6426 LIBINPUT_EXPORT int 6427+libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType) 6428+{ 6429+ if (device == NULL) { 6430+ return -1; 6431+ } 6432+ return evdev_device_touch_btn_tool_type_down((struct evdev_device *)device, btnToolType); 6433+} 6434+ 6435+LIBINPUT_EXPORT int 6436 libinput_device_switch_has_switch(struct libinput_device *device, 6437 enum libinput_switch sw) 6438 { 6439@@ -3536,7 +4583,8 @@ 6440 LIBINPUT_EVENT_POINTER_SCROLL_WHEEL, 6441 LIBINPUT_EVENT_POINTER_SCROLL_FINGER, 6442 LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS, 6443- LIBINPUT_EVENT_POINTER_AXIS); 6444+ LIBINPUT_EVENT_POINTER_AXIS, 6445+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD); 6446 6447 return &event->base; 6448 } 6449@@ -3557,6 +4605,19 @@ 6450 } 6451 6452 LIBINPUT_EXPORT struct libinput_event * 6453+libinput_event_touchpad_get_base_event(struct libinput_event_touch *event) 6454+{ 6455+ require_event_type(libinput_event_get_context(&event->base), 6456+ event->base.type, 6457+ NULL, 6458+ LIBINPUT_EVENT_TOUCHPAD_DOWN, 6459+ LIBINPUT_EVENT_TOUCHPAD_UP, 6460+ LIBINPUT_EVENT_TOUCHPAD_MOTION); 6461+ 6462+ return &event->base; 6463+} 6464+ 6465+LIBINPUT_EXPORT struct libinput_event * 6466 libinput_event_gesture_get_base_event(struct libinput_event_gesture *event) 6467 { 6468 require_event_type(libinput_event_get_context(&event->base), 6469@@ -4593,3 +5654,162 @@ 6470 } 6471 } 6472 #endif 6473+ 6474+LIBINPUT_EXPORT struct libinput_event_joystick_button* 6475+libinput_event_get_joystick_pointer_button_event(struct libinput_event* event) 6476+{ 6477+ if (!event) 6478+ return 0; 6479+ 6480+ require_event_type(libinput_event_get_context(event), 6481+ event->type, 6482+ NULL, 6483+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6484+ 6485+ return (struct libinput_event_joystick_button*)event; 6486+} 6487+ 6488+LIBINPUT_EXPORT uint64_t 6489+libinput_event_joystick_button_time(struct libinput_event_joystick_button* event) 6490+{ 6491+ if (!event) 6492+ return 0; 6493+ 6494+ require_event_type(libinput_event_get_context(&event->base), 6495+ event->base.type, 6496+ 0, 6497+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6498+ 6499+ return event->time; 6500+} 6501+ 6502+LIBINPUT_EXPORT uint32_t 6503+libinput_event_joystick_button_get_key(struct libinput_event_joystick_button* event) 6504+{ 6505+ if (!event) 6506+ return 0; 6507+ 6508+ require_event_type(libinput_event_get_context(&event->base), 6509+ event->base.type, 6510+ 0, 6511+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6512+ 6513+ return event->key; 6514+} 6515+ 6516+LIBINPUT_EXPORT enum libinput_button_state 6517+libinput_event_joystick_button_get_key_state(struct libinput_event_joystick_button* event) 6518+{ 6519+ if (!event) 6520+ return 0; 6521+ 6522+ require_event_type(libinput_event_get_context(&event->base), 6523+ event->base.type, 6524+ 0, 6525+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6526+ 6527+ return event->state; 6528+} 6529+ 6530+LIBINPUT_EXPORT uint32_t 6531+libinput_event_joystick_button_get_seat_key_count(struct libinput_event_joystick_button* event) 6532+{ 6533+ if (!event) 6534+ return 0; 6535+ 6536+ require_event_type(libinput_event_get_context(&event->base), 6537+ event->base.type, 6538+ 0, 6539+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6540+ 6541+ return event->seat_key_count; 6542+} 6543+ 6544+LIBINPUT_EXPORT int 6545+libinput_event_joystick_button_get_value(struct libinput_event_joystick_button* event) 6546+{ 6547+ if (!event) 6548+ return 0; 6549+ 6550+ require_event_type(libinput_event_get_context(&event->base), 6551+ event->base.type, 6552+ 0, 6553+ LIBINPUT_EVENT_JOYSTICK_BUTTON); 6554+ 6555+ return event->value; 6556+} 6557+ 6558+LIBINPUT_EXPORT double 6559+libinput_event_touch_get_pressure(struct libinput_event_touch *event) 6560+{ 6561+ require_event_type(libinput_event_get_context(&event->base), 6562+ event->base.type, 6563+ 0, 6564+ LIBINPUT_EVENT_TOUCH_DOWN, 6565+ LIBINPUT_EVENT_TOUCH_UP, 6566+ LIBINPUT_EVENT_TOUCH_MOTION, 6567+ LIBINPUT_EVENT_TOUCH_CANCEL, 6568+ LIBINPUT_EVENT_TOUCH_FRAME); 6569+ 6570+ struct libinput_device* device = libinput_event_get_device(&event->base); 6571+ if (device == NULL) { 6572+ return 0.0; 6573+ } 6574+ struct evdev_device* evDevice = evdev_device(device); 6575+ if (evDevice == NULL) { 6576+ return 0.0; 6577+ } 6578+ 6579+ const struct input_absinfo* absInfo = evDevice->is_mt ? libevdev_get_abs_info(evDevice->evdev, ABS_MT_PRESSURE) 6580+ : libevdev_get_abs_info(evDevice->evdev, ABS_PRESSURE); 6581+ if (!absInfo) { 6582+ return 0.0; 6583+ } 6584+ double range = absInfo->maximum; 6585+ double value = event->pressure / range; 6586+ return max(0.0, value); 6587+} 6588+ 6589+LIBINPUT_EXPORT int32_t 6590+libinput_event_touch_get_tool_type(struct libinput_event_touch *event) 6591+{ 6592+ require_event_type(libinput_event_get_context(&event->base), 6593+ event->base.type, 6594+ 0, 6595+ LIBINPUT_EVENT_TOUCH_DOWN, 6596+ LIBINPUT_EVENT_TOUCH_UP, 6597+ LIBINPUT_EVENT_TOUCH_MOTION); 6598+ 6599+ return event->tool_type; 6600+} 6601+ 6602+LIBINPUT_EXPORT int32_t 6603+libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event) 6604+{ 6605+ require_event_type(libinput_event_get_context(&event->base), 6606+ event->base.type, 6607+ 0, 6608+ LIBINPUT_EVENT_TOUCH_DOWN, 6609+ LIBINPUT_EVENT_TOUCH_UP, 6610+ LIBINPUT_EVENT_TOUCH_MOTION, 6611+ LIBINPUT_EVENT_TOUCH_CANCEL, 6612+ LIBINPUT_EVENT_TOUCH_FRAME); 6613+ 6614+ return event->axis.major; 6615+} 6616+ 6617+LIBINPUT_EXPORT int32_t 6618+libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event) 6619+{ 6620+ require_event_type(libinput_event_get_context(&event->base), 6621+ event->base.type, 6622+ 0, 6623+ LIBINPUT_EVENT_TOUCH_DOWN, 6624+ LIBINPUT_EVENT_TOUCH_UP, 6625+ LIBINPUT_EVENT_TOUCH_MOTION, 6626+ LIBINPUT_EVENT_TOUCH_CANCEL, 6627+ LIBINPUT_EVENT_TOUCH_FRAME); 6628+ 6629+ return event->axis.minor; 6630+} 6631+ 6632diff -Naur old/src/libinput.h new/src/libinput.h 6633--- old/src/libinput.h 2021-01-01 00:00:00.000000000 +0000 6634+++ new/src/libinput.h 2021-01-01 00:00:00.000000000 +0000 6635@@ -196,6 +196,22 @@ 6636 LIBINPUT_DEVICE_CAP_TABLET_PAD = 4, 6637 LIBINPUT_DEVICE_CAP_GESTURE = 5, 6638 LIBINPUT_DEVICE_CAP_SWITCH = 6, 6639+ LIBINPUT_DEVICE_CAP_JOYSTICK = 7, 6640+}; 6641+ 6642+enum evdev_device_udev_tags { 6643+ EVDEV_UDEV_TAG_INPUT = 1 << 0, 6644+ EVDEV_UDEV_TAG_KEYBOARD = 1 << 1, 6645+ EVDEV_UDEV_TAG_MOUSE = 1 << 2, 6646+ EVDEV_UDEV_TAG_TOUCHPAD = 1 << 3, 6647+ EVDEV_UDEV_TAG_TOUCHSCREEN = 1 << 4, 6648+ EVDEV_UDEV_TAG_TABLET = 1 << 5, 6649+ EVDEV_UDEV_TAG_JOYSTICK = 1 << 6, 6650+ EVDEV_UDEV_TAG_ACCELEROMETER = 1 << 7, 6651+ EVDEV_UDEV_TAG_TABLET_PAD = 1 << 8, 6652+ EVDEV_UDEV_TAG_POINTINGSTICK = 1 << 9, 6653+ EVDEV_UDEV_TAG_TRACKBALL = 1 << 10, 6654+ EVDEV_UDEV_TAG_SWITCH = 1 << 11, 6655 }; 6656 6657 /** 6658@@ -321,6 +337,49 @@ 6659 }; 6660 6661 /** 6662+ * @ingroup event_joystick 6663+ * 6664+ * The source for a @ref LIBINPUT_EVENT_POINTER_AXIS event. See 6665+ * libinput_event_get_joystick_axis_event() for details. 6666+ * 6667+ * @since 1.16.4 6668+ */ 6669+enum libinput_joystick_axis_source { 6670+ LIBINPUT_JOYSTICK_AXIS_SOURCE_UNKNOWN = 0, 6671+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X = 1 << 0, 6672+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y = 1 << 1, 6673+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z = 1 << 2, 6674+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX = 1 << 3, 6675+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY = 1 << 4, 6676+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ = 1 << 5, 6677+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE = 1 << 6, 6678+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RUDDER = 1 << 7, 6679+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_WHEEL = 1 << 8, 6680+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS = 1 << 9, 6681+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE = 1 << 10, 6682+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X = 1 << 11, 6683+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y = 1 << 12, 6684+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1X = 1 << 13, 6685+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1Y = 1 << 14, 6686+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2X = 1 << 15, 6687+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2Y = 1 << 16, 6688+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3X = 1 << 17, 6689+ LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3Y = 1 << 18, 6690+}; 6691+ 6692+#define MAX_SOLTED_COORDS_NUM 10 6693+struct sloted_coords { 6694+ int32_t is_active; 6695+ float x; 6696+ float y; 6697+}; 6698+ 6699+struct sloted_coords_info { 6700+ struct sloted_coords coords[MAX_SOLTED_COORDS_NUM]; 6701+ unsigned int active_count; 6702+}; 6703+ 6704+/** 6705 * @ingroup device 6706 * 6707 * Available tool types for a device with the @ref 6708@@ -393,6 +452,17 @@ 6709 LIBINPUT_TABLET_TOOL_TIP_DOWN = 1, 6710 }; 6711 6712+struct libinput_event_joystick_axis_abs_info { 6713+ int32_t code; 6714+ int32_t value; 6715+ int32_t minimum; 6716+ int32_t maximum; 6717+ int32_t fuzz; 6718+ int32_t flat; 6719+ int32_t resolution; 6720+ float standardValue; 6721+}; 6722+ 6723 /** 6724 * @defgroup tablet_pad_modes Tablet pad modes 6725 * 6726@@ -822,6 +892,13 @@ 6727 */ 6728 LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS, 6729 6730+ LIBINPUT_EVENT_POINTER_TAP, 6731+ LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD, 6732+ LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD, 6733+ 6734+ LIBINPUT_EVENT_JOYSTICK_BUTTON = 450, 6735+ LIBINPUT_EVENT_JOYSTICK_AXIS, 6736+ 6737 LIBINPUT_EVENT_TOUCH_DOWN = 500, 6738 LIBINPUT_EVENT_TOUCH_UP, 6739 LIBINPUT_EVENT_TOUCH_MOTION, 6740@@ -832,6 +909,10 @@ 6741 */ 6742 LIBINPUT_EVENT_TOUCH_FRAME, 6743 6744+ LIBINPUT_EVENT_TOUCHPAD_DOWN = 550, 6745+ LIBINPUT_EVENT_TOUCHPAD_UP, 6746+ LIBINPUT_EVENT_TOUCHPAD_MOTION, 6747+ 6748 /** 6749 * One or more axes have changed state on a device with the @ref 6750 * LIBINPUT_DEVICE_CAP_TABLET_TOOL capability. This event is only sent 6751@@ -1084,6 +1165,19 @@ 6752 /** 6753 * @ingroup event 6754 * 6755+ * Return the touchpad event that is this input event. If the event type does 6756+ * not match the touchpad event types, this function returns NULL. 6757+ * 6758+ * The inverse of this function is libinput_event_touchpad_get_base_event(). 6759+ * 6760+ * @return A touch event, or NULL for other events 6761+ */ 6762+struct libinput_event_touch * 6763+libinput_event_get_touchpad_event(struct libinput_event *event); 6764+ 6765+/** 6766+ * @ingroup event 6767+ * 6768 * Return the gesture event that is this input event. If the event type does 6769 * not match the gesture event types, this function returns NULL. 6770 * 6771@@ -1486,6 +1580,21 @@ 6772 /** 6773 * @ingroup event_pointer 6774 * 6775+ * For the button of a @ref LIBINPUT_EVENT_POINTER_BUTTON event, return the 6776+ * total number of fingers on touchpad. 6777+ * 6778+ * @note It is an application bug to call this function for events other than 6779+ * @ref LIBINPUT_EVENT_POINTER_BUTTON. For other events, this function 6780+ * returns 0. 6781+ * 6782+ * @return The finger counts for touchpad button event 6783+ */ 6784+uint32_t 6785+libinput_event_pointer_get_finger_count( 6786+ struct libinput_event_pointer *event); 6787+/** 6788+ * @ingroup event_pointer 6789+ * 6790 * Check if the event has a valid value for the given axis. 6791 * 6792 * If this function returns non-zero for an axis and 6793@@ -1870,6 +1979,120 @@ 6794 uint32_t height); 6795 6796 /** 6797+ * @brief 获取触摸屏的工具类型区域属性 6798+ */ 6799+int32_t 6800+libinput_event_touch_get_tool_type(struct libinput_event_touch *event); 6801+ 6802+/** 6803+ * @ingroup event_touch 6804+ * 6805+ * Returns the absolute x coordinate of the center point of the current tool 6806+ * area, in mm from the upper left corner of the device. To get the 6807+ * corresponding output screen coordinates, use 6808+ * libinput_event_touch_get_tool_x_transformed(). 6809+ * 6810+ * @param event The libinput touch event 6811+ * @return The current absolute x coordinate 6812+ */ 6813+double 6814+libinput_event_touch_get_tool_x(struct libinput_event_touch *event); 6815+ 6816+/** 6817+ * @ingroup event_touch 6818+ * 6819+ * Returns the absolute x coordinate of the center point of the current tool 6820+ * area, converted to screen coordinates. 6821+ * 6822+ * @param event The libinput touch event 6823+ * @param width The current output screen width 6824+ * @return The current absolute x coordinate transformed to a screen coordinate 6825+ */ 6826+double 6827+libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event, 6828+ uint32_t width); 6829+ 6830+/** 6831+ * @ingroup event_touch 6832+ * 6833+ * Returns the absolute y coordinate of the center point of the current tool 6834+ * area, in mm from the upper left corner of the device. To get the 6835+ * corresponding output screen coordinates, use 6836+ * libinput_event_touch_get_tool_y_transformed(). 6837+ * 6838+ * @param event The libinput touch event 6839+ * @return The current absolute y coordinate 6840+ */ 6841+double 6842+libinput_event_touch_get_tool_y(struct libinput_event_touch *event); 6843+ 6844+/** 6845+ * @ingroup event_touch 6846+ * 6847+ * Returns the absolute y coordinate of the center point of the current tool 6848+ * area, converted to screen coordinates. 6849+ * 6850+ * @param event The libinput touch event 6851+ * @param height The current output screen height 6852+ * @return The current absolute y coordinate transformed to a screen coordinate 6853+ */ 6854+double 6855+libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event, 6856+ uint32_t height); 6857+ 6858+/** 6859+ * @ingroup event_touch 6860+ * 6861+ * Returns the width of the current tool area. To get the corresponding output 6862+ * screen width, use 6863+ * libinput_event_touch_get_tool_width_transformed(). 6864+ * 6865+ * @param event The libinput touch event 6866+ * @return The current width 6867+ */ 6868+double 6869+libinput_event_touch_get_tool_width(struct libinput_event_touch *event); 6870+ 6871+/** 6872+ * @ingroup event_touch 6873+ * 6874+ * Returns the width of the current tool area, converted to screen width. 6875+ * 6876+ * @param event The libinput touch event 6877+ * @param width The current output screen width 6878+ * @return Convert current width to screen width 6879+ */ 6880+double 6881+libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event, 6882+ uint32_t width); 6883+ 6884+/** 6885+ * @ingroup event_touch 6886+ * 6887+ * Returns the height of the current tool area. To get the corresponding output 6888+ * screen height, use 6889+ * libinput_event_touch_get_tool_height_transformed(). 6890+ * 6891+ * @param event The libinput touch event 6892+ * @return The current height 6893+ */ 6894+double 6895+libinput_event_touch_get_tool_height(struct libinput_event_touch *event); 6896+ 6897+/** 6898+ * @ingroup event_touch 6899+ * 6900+ * Returns the height of the current tool area, converted to screen height. 6901+ * 6902+ * @param event The libinput touch event 6903+ * @param height The current output screen height 6904+ * @return Convert current height to screen height 6905+ */ 6906+double 6907+libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event, 6908+ uint32_t height); 6909+ 6910+/** 6911 * @ingroup event_touch 6912 * 6913 * @return The generic libinput_event of this event 6914@@ -1878,6 +2101,228 @@ 6915 libinput_event_touch_get_base_event(struct libinput_event_touch *event); 6916 6917 /** 6918+ * @defgroup event_touch Touchpad events 6919+ * 6920+ * Events from absolute touchpad devices. 6921+ */ 6922+ 6923+/** 6924+ * @ingroup event_touch 6925+ * 6926+ * @note Timestamps may not always increase. See the libinput documentation 6927+ * for more details. 6928+ * 6929+ * @return The event time for this event 6930+ */ 6931+uint32_t 6932+libinput_event_touchpad_get_time(struct libinput_event_touch *event); 6933+ 6934+/** 6935+ * @ingroup event_touch 6936+ * 6937+ * @note Timestamps may not always increase. See the libinput documentation 6938+ * for more details. 6939+ * 6940+ * @return The event time for this event in microseconds 6941+ */ 6942+uint64_t 6943+libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event); 6944+ 6945+/** 6946+ * @ingroup event_touch 6947+ * 6948+ * Get the slot of this touchpad event. See the kernel's multitouch 6949+ * protocol B documentation for more information. 6950+ * 6951+ * If the touchpad event has no assigned slot, for example if it is from a 6952+ * single touchpad device, this function returns -1. 6953+ * 6954+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 6955+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION, 6956+ * this function returns 0. 6957+ * 6958+ * @note It is an application bug to call this function for events of type 6959+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or 6960+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION. 6961+ * 6962+ * @return The slot of this touchpad event 6963+ */ 6964+int32_t 6965+libinput_event_touchpad_get_slot(struct libinput_event_touch *event); 6966+ 6967+/** 6968+ * @ingroup event_touch 6969+ * 6970+ * Get the seat slot of the touchpad event. A seat slot is a non-negative seat 6971+ * wide unique identifier of an active touchpad point. 6972+ * 6973+ * Events from single touchpad devices will be represented as one individual 6974+ * touchpad point per device. 6975+ * 6976+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 6977+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION, 6978+ * this function returns 0. 6979+ * 6980+ * @note It is an application bug to call this function for events of type 6981+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or 6982+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION. 6983+ * 6984+ * @return The seat slot of the touchpad event 6985+ */ 6986+int32_t 6987+libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event); 6988+ 6989+/** 6990+ * @ingroup event_touch 6991+ * 6992+ * Return the current absolute x coordinate of the touchpad event, in mm from 6993+ * the top left corner of the device. 6994+ * 6995+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 6996+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 6997+ * 6998+ * @note It is an application bug to call this function for events of type 6999+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref 7000+ * LIBINPUT_EVENT_TOUCHPAD_MOTION. 7001+ * 7002+ * @param event The libinput touchpad event 7003+ * @return The current absolute x coordinate 7004+ */ 7005+double 7006+libinput_event_touchpad_get_x(struct libinput_event_touch *event); 7007+ 7008+/** 7009+ * @ingroup event_touch 7010+ * 7011+ * Return the current absolute y coordinate of the touchpad event, in mm from 7012+ * the top left corner of the device. 7013+ * 7014+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 7015+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 7016+ * 7017+ * @note It is an application bug to call this function for events of type 7018+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref 7019+ * LIBINPUT_EVENT_TOUCHPAD_MOTION. 7020+ * 7021+ * @param event The libinput touchpad event 7022+ * @return The current absolute y coordinate 7023+ */ 7024+double 7025+libinput_event_touchpad_get_y(struct libinput_event_touch *event); 7026+ 7027+/** 7028+ * @ingroup event_touch 7029+ * 7030+ * Get the pressure of the touch pad 7031+ * 7032+ * @param event The libinput touch event 7033+ * @return Touchpad pressure value 7034+ * 7035+ */ 7036+double 7037+libinput_event_touchpad_get_pressure(struct libinput_event_touch *event); 7038+ 7039+/** 7040+ * @ingroup event_touch 7041+ * 7042+ * Gets the long axis of the touchpoint region of the touchpad 7043+ * 7044+ * @param event The libinput touch event 7045+ * @return The long axis value of the touchpoint area of the touchpad 7046+ */ 7047+int32_t 7048+libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event); 7049+ 7050+/** 7051+ * @ingroup event_touch 7052+ * 7053+ * Gets the short axis of the touchpoint region of the touchpad 7054+ * 7055+ * @param event The libinput touch event 7056+ * @return The short axis value of the touchpoint area of the touchpad 7057+ */ 7058+int32_t 7059+libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event); 7060+ 7061+/** 7062+ * @brief 获取触摸板的工具类型区域属性 7063+ */ 7064+int32_t 7065+libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event); 7066+ 7067+/** 7068+ * @brief 获取触摸板工具类型按钮是否按下 7069+ */ 7070+int32_t 7071+libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType); 7072+ 7073+/** 7074+ * @ingroup event_touch 7075+ * 7076+ * @return The generic libinput_event of this event 7077+ */ 7078+struct libinput_event * 7079+libinput_event_touchpad_get_base_event(struct libinput_event_touch *event); 7080+ 7081+/** 7082+ * @ingroup event_touch 7083+ * 7084+ * Return the X coordinate of the center of the contact tool contour, in mm from 7085+ * the top left corner of the device. 7086+ * 7087+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 7088+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 7089+ * 7090+ * @param event The libinput touchpad event 7091+ * @return The X coordinate of the center of the contact tool contour 7092+ */ 7093+double 7094+libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event); 7095+ 7096+/** 7097+ * @ingroup event_touch 7098+ * 7099+ * Return the Y coordinate of the center of the contact tool contour, in mm from 7100+ * the top left corner of the device. 7101+ * 7102+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 7103+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 7104+ * 7105+ * @param event The libinput touchpad event 7106+ * @return The Y coordinate of the center of the contact tool contour 7107+ */ 7108+double 7109+libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event); 7110+ 7111+/** 7112+ * @ingroup event_touch 7113+ * 7114+ * Return the width of the current tool area. 7115+ * 7116+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 7117+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 7118+ * 7119+ * @param event The libinput touchpad event 7120+ * @return The width of the current tool area 7121+ */ 7122+double 7123+libinput_event_touchpad_get_tool_width(struct libinput_event_touch *event); 7124+ 7125+/** 7126+ * @ingroup event_touch 7127+ * 7128+ * Return the height of the current tool area. 7129+ * 7130+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref 7131+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0. 7132+ * 7133+ * @param event The libinput touchpad event 7134+ * @return The height of the current tool area 7135+ */ 7136+double 7137+libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event); 7138+ 7139+/** 7140 * @defgroup event_gesture Gesture events 7141 * 7142 * Gesture events are generated when a gesture is recognized on a touchpad. 7143@@ -2090,6 +2535,49 @@ 7144 libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event); 7145 7146 /** 7147+ * 获取gesture中手指的坐标信息, idx表示手指的索引 7148+ */ 7149+int 7150+libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx); 7151+int 7152+libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx); 7153+/** 7154+ * 获取带slot的touches信息, 仅支持LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE 7155+ */ 7156+struct sloted_coords_info * 7157+libinput_event_gesture_get_solt_touches(struct libinput_event_gesture *event); 7158+ 7159+/** 7160+ * @brief Obtain the device values the EV_LED event type 7161+ * 7162+ * @param device A current input device 7163+ * @return int Obtained is Supported 7164+ */ 7165+int libinput_has_event_led_type(struct libinput_device *device); 7166+ 7167+/** 7168+ * @brief Obtain the function key enablement status of a keyboard device 7169+ * 7170+ * @param device A current input device 7171+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, 7172+ * given code (see linux/input-event-codes.h). 7173+ * @return int Obtained state 7174+ */ 7175+int libinput_get_funckey_state(struct libinput_device *device, unsigned int code); 7176+ 7177+/** 7178+ * @brief Turn an LED on or off. Convenience function, if you need to modify multiple 7179+ * LEDs simultaneously, use libinput_set_led_state() instead. 7180+ * 7181+ * @param device A current input device 7182+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, 7183+ * given code (see linux/input-event-codes.h). 7184+ * @param state value Specifies whether to turn the LED on or off 7185+ * @return int 0 on success, or a negative errno on failure 7186+ */ 7187+int libinput_set_led_state(struct libinput_device *device, unsigned int code, unsigned int state); 7188+ 7189+/** 7190 * @defgroup event_tablet Tablet events 7191 * 7192 * Events that come from tools on tablet devices. For events from the pad, 7193@@ -2817,6 +3305,19 @@ 7194 /** 7195 * @ingroup event_tablet 7196 * 7197+ * Get the stylus event type reported from evdev_tablet 7198+ * 7199+ * @param event The libinput tablet tool event 7200+ * @return Tool type for stylus events 7201+ * 7202+ * @since 1.2 7203+ */ 7204+int32_t 7205+libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event); 7206+ 7207+/** 7208+ * @ingroup event_tablet 7209+ * 7210 * Return the high-level tool type for a tool object. 7211 * 7212 * The high level tool describes general interaction expected with the tool. 7213@@ -3663,6 +4164,56 @@ 7214 int 7215 libinput_dispatch(struct libinput *libinput); 7216 7217+/**************************************************************************** 7218+* @brief : brief 7219+* @author : fms 7220+* @date : 2021/3/8 20:55 7221+* @version : ver 1.0 7222+* @inparam :libinput event 7223+* @outparam : 7224+*****************************************************************************/ 7225+void 7226+libinput_post_handle_event(struct libinput* libinput, 7227+ struct libinput_event* event); 7228+ 7229+/**************************************************************************** 7230+* @brief : get joystick button event 7231+* @author : fms 7232+* @date : 2021/3/12 10:56 7233+* @version : ver 1.0 7234+* @inparam : 7235+* @outparam : 7236+*****************************************************************************/ 7237+struct libinput_event_joystick_button* 7238+libinput_event_get_joystick_button_event(struct libinput_event* event); 7239+ 7240+/**************************************************************************** 7241+* @brief : get joystick axis event 7242+* @author : fms 7243+* @date : 2021/3/12 10:56 7244+* @version : ver 1.0 7245+* @inparam : 7246+* @outparam : 7247+*****************************************************************************/ 7248+struct libinput_event_joystick_axis* 7249+ libinput_event_get_joystick_axis_event(struct libinput_event* event); 7250+/** 7251+ * @brief 获取轴事件的时间 7252+ */ 7253+uint64_t 7254+libinput_event_get_joystick_axis_time(struct libinput_event_joystick_axis *event); 7255+ 7256+/** 7257+ * @brief 获取joystick指定轴的数据是否变化 7258+*/ 7259+int32_t libinput_event_get_joystick_axis_value_is_changed(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis); 7260+ 7261+/** 7262+ * @brief 获取joystick指定轴的abs信息 7263+*/ 7264+struct libinput_event_joystick_axis_abs_info * 7265+libinput_event_get_joystick_axis_abs_info(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis); 7266+ 7267 /** 7268 * @ingroup base 7269 * 7270@@ -4133,6 +4684,42 @@ 7271 const char * 7272 libinput_device_get_name(struct libinput_device *device); 7273 7274+/** @brief 获取设备类型*/ 7275+enum evdev_device_udev_tags 7276+libinput_device_get_tags(struct libinput_device* device); 7277+ 7278+/** @brief 设备按键能力查询*/ 7279+int32_t 7280+libinput_device_has_key(struct libinput_device* device, int32_t keyCode); 7281+ 7282+/** @brief 获取设备特定轴的最小值*/ 7283+int32_t 7284+libinput_device_get_axis_min(struct libinput_device* device, int32_t code); 7285+ 7286+/** @brief 获取设备特定轴的最大值*/ 7287+int32_t 7288+libinput_device_get_axis_max(struct libinput_device* device, int32_t code); 7289+ 7290+/** @brief 获取设备特定轴的fuzz值*/ 7291+int32_t 7292+libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code); 7293+ 7294+/** @brief 获取设备特定轴的flat值*/ 7295+int32_t 7296+libinput_device_get_axis_flat(struct libinput_device* device, int32_t code); 7297+ 7298+/** @brief 获取设备特定轴的resolution值*/ 7299+int32_t 7300+libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code); 7301+ 7302+/** @brief 获取设备的bustype值*/ 7303+unsigned int 7304+libinput_device_get_id_bustype(struct libinput_device* device); 7305+ 7306+/** @brief 获取设备的version值*/ 7307+unsigned int 7308+libinput_device_get_id_version(struct libinput_device* device); 7309+ 7310 /** 7311 * @ingroup device 7312 * 7313@@ -4343,6 +4930,12 @@ 7314 libinput_device_touch_get_touch_count(struct libinput_device *device); 7315 7316 /** 7317+ * @brief 获取触摸屏工具类型按钮是否按下 7318+ */ 7319+int 7320+libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType); 7321+ 7322+/** 7323 * @ingroup device 7324 * 7325 * Check if a @ref LIBINPUT_DEVICE_CAP_SWITCH device has a switch of the 7326@@ -5543,6 +6136,9 @@ 7327 enum libinput_config_click_method 7328 libinput_device_config_click_get_default_method(struct libinput_device *device); 7329 7330+uint64_t 7331+libinput_event_get_sensortime(struct libinput_event *event); 7332+ 7333 /** 7334 * @ingroup config 7335 */ 7336@@ -6124,7 +6720,102 @@ 7337 unsigned int 7338 libinput_device_config_rotation_get_default_angle(struct libinput_device *device); 7339 7340+/** 7341+ * @ingroup event 7342+ * 7343+ * Get the struct libinput_event_joystick_button from the event. 7344+ * 7345+ * @param event The libinput event 7346+ * @return The libinput_event_joystick_button for this event. 7347+ */ 7348+struct libinput_event_joystick_button* 7349+libinput_event_get_joystick_pointer_button_event(struct libinput_event* event); 7350+ 7351+/** 7352+ * @ingroup event 7353+ * 7354+ * Get the time from the event. 7355+ * 7356+ * @param event The libinput_event_joystick_button 7357+ * @return The time for this event. 7358+ */ 7359+uint64_t libinput_event_joystick_button_time(struct libinput_event_joystick_button* event); 7360+ 7361+/** 7362+ * @ingroup event 7363+ * 7364+ * Get the key value from the event. 7365+ * 7366+ * @param event The libinput_event_joystick_button 7367+ * @return The key value for this event. 7368+ */ 7369+uint32_t libinput_event_joystick_button_get_key(struct libinput_event_joystick_button* event); 7370+ 7371+/** 7372+ * @ingroup event 7373+ * 7374+ * Get the seat key count from the event. 7375+ * 7376+ * @param event The libinput_event_joystick_button 7377+ * @return The seat key count for this event. 7378+ */ 7379+uint32_t libinput_event_joystick_button_get_seat_key_count(struct libinput_event_joystick_button* event); 7380+ 7381+/** 7382+ * @ingroup event 7383+ * 7384+ * Get the value count from the event. 7385+ * 7386+ * @param event The libinput_event_joystick_button 7387+ * @return The value for this event. 7388+ */ 7389+int libinput_event_joystick_button_get_value(struct libinput_event_joystick_button* event); 7390+ 7391+/** 7392+ * @ingroup config 7393+ * 7394+ * Get the pressure of the touch screen 7395+ * 7396+ * @param Carried libinput event 7397+ * @return Pressure value of touch screen 7398+ * 7399+ * @since 1.4 7400+ */ 7401+double 7402+libinput_event_touch_get_pressure(struct libinput_event_touch* event); 7403+ 7404+/** 7405+ * @ingroup event_touch 7406+ * 7407+ * Gets the long axis of the touch point region of the touch screen 7408+ * 7409+ * @param event The libinput touch event 7410+ * @return Long axis value of touch point region 7411+ */ 7412+int32_t 7413+libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event); 7414+ 7415+/** 7416+ * @ingroup event_touch 7417+ * 7418+ * Gets the short axis of the touch point region of the touch screen 7419+ * 7420+ * @param event The libinput touch event 7421+ * @return Short axis value of touch point region 7422+ */ 7423+int32_t 7424+libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event); 7425+ 7426+const char* 7427+libinput_device_get_phys(struct libinput_device* device); 7428+ 7429+const char* 7430+libinput_device_get_uniq(struct libinput_device* device); 7431+ 7432+enum libinput_button_state 7433+libinput_event_joystick_button_get_key_state(struct libinput_event_joystick_button* event); 7434 #ifdef __cplusplus 7435 } 7436 #endif 7437 #endif /* LIBINPUT_H */ 7438+ 7439diff -Naur old/src/udev-seat.c new/src/udev-seat.c 7440--- old/src/udev-seat.c 2021-01-01 00:00:00.000000000 +0000 7441+++ new/src/udev-seat.c 2021-01-01 00:00:00.000000000 +0000 7442@@ -191,6 +191,7 @@ 7443 7444 /* Skip unconfigured device. udev will send an event 7445 * when device is fully configured */ 7446+/* 7447 if (!udev_device_get_is_initialized(device)) { 7448 log_debug(&input->base, 7449 "%-7s - skip unconfigured input device '%s'\n", 7450@@ -199,6 +200,13 @@ 7451 udev_device_unref(device); 7452 continue; 7453 } 7454+*/ 7455+ if (!udev_device_get_is_initialized(device)) { 7456+ log_info(&input->base, 7457+ "%-7s - unconfigured input device '%s'\n", 7458+ sysname, 7459+ udev_device_get_devnode(device)); 7460+ } 7461 7462 if (device_added(device, input, NULL) < 0) { 7463 udev_device_unref(device); 7464diff -Naur old/src/util-strings.h new/src/util-strings.h 7465--- old/src/util-strings.h 2021-01-01 00:00:00.000000000 +0000 7466+++ new/src/util-strings.h 2021-01-01 00:00:00.000000000 +0000 7467@@ -311,7 +311,7 @@ 7468 if (npairs == 0) 7469 goto error; 7470 7471- result = zalloc(npairs * sizeof *result); 7472+ result = (struct key_value_double *)zalloc(npairs * sizeof *result); 7473 7474 for (pair = pairs; *pair; pair++) { 7475 char **kv = strv_from_string(*pair, kv_separator); 7476diff -Naur old/src/util-time.h new/src/util-time.h 7477--- old/src/util-time.h 2021-01-01 00:00:00.000000000 +0000 7478+++ new/src/util-time.h 2021-01-01 00:00:00.000000000 +0000 7479@@ -103,7 +103,8 @@ 7480 static inline struct human_time 7481 to_human_time(uint64_t us) 7482 { 7483- struct human_time t; 7484+ uint64_t l = 0; 7485+ struct human_time t = {0, NULL}; 7486 struct c { 7487 const char *unit; 7488 unsigned int change_from_previous; 7489@@ -114,7 +115,7 @@ 7490 {"s", 1000, 120}, 7491 {"min", 60, 120}, 7492 {"h", 60, 48}, 7493- {"d", 24, ~0}, 7494+ {"d", 24, ~l}, 7495 }; 7496 struct c *c; 7497 uint64_t value = us; 7498@@ -127,6 +128,6 @@ 7499 return t; 7500 } 7501 } 7502- 7503- assert(!"We should never get here"); 7504+return t; 7505+ //assert(1); 7506 } 7507diff -Naur old/tools/libinput-debug-events.c new/tools/libinput-debug-events.c 7508--- old/tools/libinput-debug-events.c 2021-01-01 00:00:00.000000000 +0000 7509+++ new/tools/libinput-debug-events.c 2021-01-01 00:00:00.000000000 +0000 7510@@ -110,6 +110,15 @@ 7511 case LIBINPUT_EVENT_TOUCH_FRAME: 7512 type = "TOUCH_FRAME"; 7513 break; 7514+ case LIBINPUT_EVENT_TOUCHPAD_DOWN: 7515+ type = "TOUCHPAD_DOWN"; 7516+ break; 7517+ case LIBINPUT_EVENT_TOUCHPAD_MOTION: 7518+ type = "TOUCHPAD_MOTION"; 7519+ break; 7520+ case LIBINPUT_EVENT_TOUCHPAD_UP: 7521+ type = "TOUCHPAD_UP"; 7522+ break; 7523 case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: 7524 type = "GESTURE_SWIPE_BEGIN"; 7525 break; 7526@@ -161,6 +170,8 @@ 7527 case LIBINPUT_EVENT_SWITCH_TOGGLE: 7528 type = "SWITCH_TOGGLE"; 7529 break; 7530+ default: 7531+ break; 7532 } 7533 7534 prefix = (last_device != dev) ? '-' : ' '; 7535@@ -289,6 +300,10 @@ 7536 LIBINPUT_DEVICE_CAP_SWITCH)) 7537 printq("S"); 7538 7539+ if (libinput_device_has_capability(dev, 7540+ LIBINPUT_DEVICE_CAP_JOYSTICK)) 7541+ printq("JOYSTICK"); 7542+ 7543 if (libinput_device_get_size(dev, &w, &h) == 0) 7544 printq(" size %.0fx%.0fmm", w, h); 7545 7546@@ -539,6 +554,15 @@ 7547 } 7548 7549 static void 7550+print_touchpad_event_without_coords(struct libinput_event *ev) 7551+{ 7552+ struct libinput_event_touch *t = libinput_event_get_touchpad_event(ev); 7553+ 7554+ print_event_time(libinput_event_touchpad_get_time(t)); 7555+ printq("\n"); 7556+} 7557+ 7558+static void 7559 print_proximity_event(struct libinput_event *ev) 7560 { 7561 struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev); 7562@@ -665,6 +689,21 @@ 7563 } 7564 7565 static void 7566+print_touchpad_event_with_coords(struct libinput_event *ev) 7567+{ 7568+ struct libinput_event_touch *t = libinput_event_get_touchpad_event(ev); 7569+ double xmm = libinput_event_touchpad_get_x(t); 7570+ double ymm = libinput_event_touchpad_get_y(t); 7571+ 7572+ print_event_time(libinput_event_touchpad_get_time(t)); 7573+ 7574+ printq("%d (%d) %5.2f/%5.2fmm\n", 7575+ libinput_event_touchpad_get_slot(t), 7576+ libinput_event_touchpad_get_seat_slot(t), 7577+ xmm, ymm); 7578+} 7579+ 7580+static void 7581 print_gesture_event_without_coords(struct libinput_event *ev) 7582 { 7583 struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev); 7584@@ -888,6 +927,15 @@ 7585 case LIBINPUT_EVENT_TOUCH_FRAME: 7586 print_touch_event(ev); 7587 break; 7588+ case LIBINPUT_EVENT_TOUCHPAD_DOWN: 7589+ print_touchpad_event_with_coords(ev); 7590+ break; 7591+ case LIBINPUT_EVENT_TOUCHPAD_MOTION: 7592+ print_touchpad_event_with_coords(ev); 7593+ break; 7594+ case LIBINPUT_EVENT_TOUCHPAD_UP: 7595+ print_touchpad_event_without_coords(ev); 7596+ break; 7597 case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN: 7598 print_gesture_event_without_coords(ev); 7599 break; 7600@@ -939,6 +987,8 @@ 7601 case LIBINPUT_EVENT_SWITCH_TOGGLE: 7602 print_switch_event(ev); 7603 break; 7604+ default: 7605+ break; 7606 } 7607 7608 libinput_event_destroy(ev); 7609diff -Naur old/tools/libinput-record.c new/tools/libinput-record.c 7610--- old/tools/libinput-record.c 2021-01-01 00:00:00.000000000 +0000 7611+++ new/tools/libinput-record.c 2021-01-01 00:00:00.000000000 +0000 7612@@ -52,6 +52,7 @@ 7613 #include "util-time.h" 7614 #include "util-input-event.h" 7615 #include "util-macros.h" 7616+#include "hm_missing.h" 7617 7618 static const int FILE_VERSION_NUMBER = 1; 7619 7620diff -Naur old/udev/libinput-device-group.c new/udev/libinput-device-group.c 7621--- old/udev/libinput-device-group.c 2021-01-01 00:00:00.000000000 +0000 7622+++ new/udev/libinput-device-group.c 2021-01-01 00:00:00.000000000 +0000 7623@@ -138,7 +138,7 @@ 7624 *product_id = pid; 7625 best_dist = dist; 7626 7627- free(*phys_attr); 7628+ free((char*)*phys_attr); 7629 *phys_attr = safe_strdup(phys); 7630 } 7631 } 7632