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