• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1Copyright (C) 2021-2024 Huawei Device Co., Ltd.
2Licensed under the Apache License, Version 2.0 (the "License");
3you may not use this file except in compliance with the License.
4You may obtain a copy of the License at\n
5
6    http://www.apache.org/licenses/LICENSE-2.0
7
8Unless required by applicable law or agreed to in writing, software
9distributed under the License is distributed on an "AS IS" BASIS,
10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11See the License for the specific language governing permissions and
12limitations under the License.
13
14diff -Naur old/export_include/libinput.h new/export_include/libinput.h
15--- old/export_include/libinput.h	2024-01-01 00:00:00.000000000 +0800
16+++ new/export_include/libinput.h	2024-01-01 00:00:00.000000000 +0800
17@@ -196,6 +196,23 @@
18 	LIBINPUT_DEVICE_CAP_TABLET_PAD = 4,
19 	LIBINPUT_DEVICE_CAP_GESTURE = 5,
20 	LIBINPUT_DEVICE_CAP_SWITCH = 6,
21+	LIBINPUT_DEVICE_CAP_JOYSTICK = 7,
22+};
23+
24+enum evdev_device_udev_tags {
25+    EVDEV_UDEV_TAG_INPUT = 1 << 0,
26+    EVDEV_UDEV_TAG_KEYBOARD = 1 << 1,
27+    EVDEV_UDEV_TAG_MOUSE = 1 << 2,
28+    EVDEV_UDEV_TAG_TOUCHPAD = 1 << 3,
29+    EVDEV_UDEV_TAG_TOUCHSCREEN = 1 << 4,
30+    EVDEV_UDEV_TAG_TABLET = 1 << 5,
31+    EVDEV_UDEV_TAG_JOYSTICK = 1 << 6,
32+    EVDEV_UDEV_TAG_ACCELEROMETER = 1 << 7,
33+    EVDEV_UDEV_TAG_TABLET_PAD = 1 << 8,
34+    EVDEV_UDEV_TAG_POINTINGSTICK = 1 << 9,
35+    EVDEV_UDEV_TAG_TRACKBALL = 1 << 10,
36+    EVDEV_UDEV_TAG_SWITCH = 1 << 11,
37+	EVDEV_UDEV_TAG_MSDP = 1 << 12,
38 };
39
40 /**
41@@ -321,6 +338,49 @@
42 };
43
44 /**
45+ * @ingroup event_joystick
46+ *
47+ * The source for a @ref LIBINPUT_EVENT_POINTER_AXIS event. See
48+ * libinput_event_get_joystick_axis_event() for details.
49+ *
50+ * @since 1.16.4
51+ */
52+enum libinput_joystick_axis_source {
53+	LIBINPUT_JOYSTICK_AXIS_SOURCE_UNKNOWN = 0,
54+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X = 1 << 0,
55+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y = 1 << 1,
56+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z = 1 << 2,
57+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX = 1 << 3,
58+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY = 1 << 4,
59+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ = 1 << 5,
60+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE = 1 << 6,
61+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RUDDER = 1 << 7,
62+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_WHEEL = 1 << 8,
63+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS = 1 << 9,
64+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE = 1 << 10,
65+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X = 1 << 11,
66+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y = 1 << 12,
67+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1X = 1 << 13,
68+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1Y = 1 << 14,
69+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2X = 1 << 15,
70+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2Y = 1 << 16,
71+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3X = 1 << 17,
72+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3Y = 1 << 18,
73+};
74+
75+#define MAX_SOLTED_COORDS_NUM 10
76+struct sloted_coords {
77+	int32_t is_active;
78+	float x;
79+	float y;
80+};
81+
82+struct sloted_coords_info {
83+	struct sloted_coords coords[MAX_SOLTED_COORDS_NUM];
84+	unsigned int active_count;
85+};
86+
87+/**
88  * @ingroup device
89  *
90  * Available tool types for a device with the @ref
91@@ -393,6 +453,17 @@
92 	LIBINPUT_TABLET_TOOL_TIP_DOWN = 1,
93 };
94
95+struct libinput_event_joystick_axis_abs_info {
96+	int32_t code;
97+	int32_t value;
98+	int32_t minimum;
99+	int32_t maximum;
100+	int32_t fuzz;
101+	int32_t flat;
102+	int32_t resolution;
103+	float	standardValue;
104+};
105+
106 /**
107  * @defgroup tablet_pad_modes Tablet pad modes
108  *
109@@ -702,6 +773,7 @@
110 	 * in tablet mode.
111 	 */
112 	LIBINPUT_SWITCH_TABLET_MODE,
113+	LIBINPUT_SWITCH_PRIVACY,
114 };
115
116 /**
117@@ -822,6 +894,16 @@
118 	 */
119 	LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
120
121+	LIBINPUT_EVENT_POINTER_TAP,
122+	LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD,
123+	LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD,
124+
125+	LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN,
126+	LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END,
127+
128+	LIBINPUT_EVENT_JOYSTICK_BUTTON = 450,
129+	LIBINPUT_EVENT_JOYSTICK_AXIS,
130+
131 	LIBINPUT_EVENT_TOUCH_DOWN = 500,
132 	LIBINPUT_EVENT_TOUCH_UP,
133 	LIBINPUT_EVENT_TOUCH_MOTION,
134@@ -832,6 +914,10 @@
135 	 */
136 	LIBINPUT_EVENT_TOUCH_FRAME,
137
138+	LIBINPUT_EVENT_TOUCHPAD_DOWN = 550,
139+	LIBINPUT_EVENT_TOUCHPAD_UP,
140+	LIBINPUT_EVENT_TOUCHPAD_MOTION,
141+
142 	/**
143 	 * One or more axes have changed state on a device with the @ref
144 	 * LIBINPUT_DEVICE_CAP_TABLET_TOOL capability. This event is only sent
145@@ -984,6 +1070,8 @@
146 	 * @since 1.7
147 	 */
148 	LIBINPUT_EVENT_SWITCH_TOGGLE = 900,
149+
150+	LIBINPUT_EVENT_MSDP = 1000,
151 };
152
153 /**
154@@ -1084,6 +1172,19 @@
155 /**
156  * @ingroup event
157  *
158+ * Return the touchpad event that is this input event. If the event type does
159+ * not match the touchpad event types, this function returns NULL.
160+ *
161+ * The inverse of this function is libinput_event_touchpad_get_base_event().
162+ *
163+ * @return A touch event, or NULL for other events
164+ */
165+struct libinput_event_touch *
166+libinput_event_get_touchpad_event(struct libinput_event *event);
167+
168+/**
169+ * @ingroup event
170+ *
171  * Return the gesture event that is this input event. If the event type does
172  * not match the gesture event types, this function returns NULL.
173  *
174@@ -1486,6 +1587,21 @@
175 /**
176  * @ingroup event_pointer
177  *
178+ * For the button of a @ref LIBINPUT_EVENT_POINTER_BUTTON event, return the
179+ * total number of fingers on touchpad.
180+ *
181+ * @note It is an application bug to call this function for events other than
182+ * @ref LIBINPUT_EVENT_POINTER_BUTTON. For other events, this function
183+ * returns 0.
184+ *
185+ * @return The finger counts for touchpad button event
186+ */
187+uint32_t
188+libinput_event_pointer_get_finger_count(
189+	struct libinput_event_pointer *event);
190+/**
191+ * @ingroup event_pointer
192+ *
193  * Check if the event has a valid value for the given axis.
194  *
195  * If this function returns non-zero for an axis and
196@@ -1870,6 +1986,120 @@
197 				       uint32_t height);
198
199 /**
200+ * @brief 获取触摸屏的工具类型区域属性
201+ */
202+int32_t
203+libinput_event_touch_get_tool_type(struct libinput_event_touch *event);
204+
205+/**
206+ * @ingroup event_touch
207+ *
208+ * Returns the absolute x coordinate of the center point of the current tool
209+ * area, in mm from the upper left corner of the device. To get the
210+ * corresponding output screen coordinates, use
211+ * libinput_event_touch_get_tool_x_transformed().
212+ *
213+ * @param event The libinput touch event
214+ * @return The current absolute x coordinate
215+ */
216+double
217+libinput_event_touch_get_tool_x(struct libinput_event_touch *event);
218+
219+/**
220+ * @ingroup event_touch
221+ *
222+ * Returns the absolute x coordinate of the center point of the current tool
223+ * area, converted to screen coordinates.
224+ *
225+ * @param event The libinput touch event
226+ * @param width The current output screen width
227+ * @return The current absolute x coordinate transformed to a screen coordinate
228+ */
229+double
230+libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event,
231+				       uint32_t width);
232+
233+/**
234+ * @ingroup event_touch
235+ *
236+ * Returns the absolute y coordinate of the center point of the current tool
237+ * area, in mm from the upper left corner of the device. To get the
238+ * corresponding output screen coordinates, use
239+ * libinput_event_touch_get_tool_y_transformed().
240+ *
241+ * @param event The libinput touch event
242+ * @return The current absolute y coordinate
243+ */
244+double
245+libinput_event_touch_get_tool_y(struct libinput_event_touch *event);
246+
247+/**
248+ * @ingroup event_touch
249+ *
250+ * Returns the absolute y coordinate of the center point of the current tool
251+ * area, converted to screen coordinates.
252+ *
253+ * @param event The libinput touch event
254+ * @param height The current output screen height
255+ * @return The current absolute y coordinate transformed to a screen coordinate
256+ */
257+double
258+libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event,
259+				       uint32_t height);
260+
261+/**
262+ * @ingroup event_touch
263+ *
264+ * Returns the width of the current tool area. To get the corresponding output
265+ * screen width, use
266+ * libinput_event_touch_get_tool_width_transformed().
267+ *
268+ * @param event The libinput touch event
269+ * @return The current width
270+ */
271+double
272+libinput_event_touch_get_tool_width(struct libinput_event_touch *event);
273+
274+/**
275+ * @ingroup event_touch
276+ *
277+ * Returns the width of the current tool area, converted to screen width.
278+ *
279+ * @param event The libinput touch event
280+ * @param width The current output screen width
281+ * @return Convert current width to screen width
282+ */
283+double
284+libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event,
285+				       uint32_t width);
286+
287+/**
288+ * @ingroup event_touch
289+ *
290+ * Returns the height of the current tool area. To get the corresponding output
291+ * screen height, use
292+ * libinput_event_touch_get_tool_height_transformed().
293+ *
294+ * @param event The libinput touch event
295+ * @return The current height
296+ */
297+double
298+libinput_event_touch_get_tool_height(struct libinput_event_touch *event);
299+
300+/**
301+ * @ingroup event_touch
302+ *
303+ * Returns the height of the current tool area, converted to screen height.
304+ *
305+ * @param event The libinput touch event
306+ * @param height The current output screen height
307+ * @return Convert current height to screen height
308+ */
309+double
310+libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event,
311+				       uint32_t height);
312+
313+/**
314  * @ingroup event_touch
315  *
316  * @return The generic libinput_event of this event
317@@ -1878,6 +2108,228 @@
318 libinput_event_touch_get_base_event(struct libinput_event_touch *event);
319
320 /**
321+ * @defgroup event_touch Touchpad events
322+ *
323+ * Events from absolute touchpad devices.
324+ */
325+
326+/**
327+ * @ingroup event_touch
328+ *
329+ * @note Timestamps may not always increase. See the libinput documentation
330+ * for more details.
331+ *
332+ * @return The event time for this event
333+ */
334+uint32_t
335+libinput_event_touchpad_get_time(struct libinput_event_touch *event);
336+
337+/**
338+ * @ingroup event_touch
339+ *
340+ * @note Timestamps may not always increase. See the libinput documentation
341+ * for more details.
342+ *
343+ * @return The event time for this event in microseconds
344+ */
345+uint64_t
346+libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event);
347+
348+/**
349+ * @ingroup event_touch
350+ *
351+ * Get the slot of this touchpad event. See the kernel's multitouch
352+ * protocol B documentation for more information.
353+ *
354+ * If the touchpad event has no assigned slot, for example if it is from a
355+ * single touchpad device, this function returns -1.
356+ *
357+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
358+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION,
359+ * this function returns 0.
360+ *
361+ * @note It is an application bug to call this function for events of type
362+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or
363+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION.
364+ *
365+ * @return The slot of this touchpad event
366+ */
367+int32_t
368+libinput_event_touchpad_get_slot(struct libinput_event_touch *event);
369+
370+/**
371+ * @ingroup event_touch
372+ *
373+ * Get the seat slot of the touchpad event. A seat slot is a non-negative seat
374+ * wide unique identifier of an active touchpad point.
375+ *
376+ * Events from single touchpad devices will be represented as one individual
377+ * touchpad point per device.
378+ *
379+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
380+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION,
381+ * this function returns 0.
382+ *
383+ * @note It is an application bug to call this function for events of type
384+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or
385+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION.
386+ *
387+ * @return The seat slot of the touchpad event
388+ */
389+int32_t
390+libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event);
391+
392+/**
393+ * @ingroup event_touch
394+ *
395+ * Return the current absolute x coordinate of the touchpad event, in mm from
396+ * the top left corner of the device.
397+ *
398+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
399+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
400+ *
401+ * @note It is an application bug to call this function for events of type
402+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref
403+ * LIBINPUT_EVENT_TOUCHPAD_MOTION.
404+ *
405+ * @param event The libinput touchpad event
406+ * @return The current absolute x coordinate
407+ */
408+double
409+libinput_event_touchpad_get_x(struct libinput_event_touch *event);
410+
411+/**
412+ * @ingroup event_touch
413+ *
414+ * Return the current absolute y coordinate of the touchpad event, in mm from
415+ * the top left corner of the device.
416+ *
417+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
418+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
419+ *
420+ * @note It is an application bug to call this function for events of type
421+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref
422+ * LIBINPUT_EVENT_TOUCHPAD_MOTION.
423+ *
424+ * @param event The libinput touchpad event
425+ * @return The current absolute y coordinate
426+ */
427+double
428+libinput_event_touchpad_get_y(struct libinput_event_touch *event);
429+
430+/**
431+ * @ingroup event_touch
432+ *
433+ * Get the pressure of the touch pad
434+ *
435+ * @param event The libinput touch event
436+ * @return Touchpad pressure value
437+ *
438+ */
439+double
440+libinput_event_touchpad_get_pressure(struct libinput_event_touch *event);
441+
442+/**
443+ * @ingroup event_touch
444+ *
445+ * Gets the long axis of the touchpoint region of the touchpad
446+ *
447+ * @param event The libinput touch event
448+ * @return The long axis value of the touchpoint area of the touchpad
449+ */
450+int32_t
451+libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event);
452+
453+/**
454+ * @ingroup event_touch
455+ *
456+ * Gets the short axis of the touchpoint region of the touchpad
457+ *
458+ * @param event The libinput touch event
459+ * @return The short axis value of the touchpoint area of the touchpad
460+ */
461+int32_t
462+libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event);
463+
464+/**
465+ * @brief 获取触摸板的工具类型区域属性
466+ */
467+int32_t
468+libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event);
469+
470+/**
471+ * @brief 获取触摸板工具类型按钮是否按下
472+ */
473+int32_t
474+libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType);
475+
476+/**
477+ * @ingroup event_touch
478+ *
479+ * @return The generic libinput_event of this event
480+ */
481+struct libinput_event *
482+libinput_event_touchpad_get_base_event(struct libinput_event_touch *event);
483+
484+/**
485+ * @ingroup event_touch
486+ *
487+ * Return the X coordinate of the center of the contact tool contour, in mm from
488+ * the top left corner of the device.
489+ *
490+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
491+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
492+ *
493+ * @param event The libinput touchpad event
494+ * @return The X coordinate of the center of the contact tool contour
495+ */
496+double
497+libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event);
498+
499+/**
500+ * @ingroup event_touch
501+ *
502+ * Return the Y coordinate of the center of the contact tool contour, in mm from
503+ * the top left corner of the device.
504+ *
505+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
506+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
507+ *
508+ * @param event The libinput touchpad event
509+ * @return The Y coordinate of the center of the contact tool contour
510+ */
511+double
512+libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event);
513+
514+/**
515+ * @ingroup event_touch
516+ *
517+ * Return the width of the current tool area.
518+ *
519+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
520+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
521+ *
522+ * @param event The libinput touchpad event
523+ * @return The width of the current tool area
524+ */
525+double
526+libinput_event_touchpad_get_tool_width(struct libinput_event_touch *event);
527+
528+/**
529+ * @ingroup event_touch
530+ *
531+ * Return the height of the current tool area.
532+ *
533+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
534+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
535+ *
536+ * @param event The libinput touchpad event
537+ * @return The height of the current tool area
538+ */
539+double
540+libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event);
541+
542+/**
543  * @defgroup event_gesture Gesture events
544  *
545  * Gesture events are generated when a gesture is recognized on a touchpad.
546@@ -2090,6 +2542,49 @@
547 libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event);
548
549 /**
550+ * 获取gesture中手指的坐标信息, idx表示手指的索引
551+ */
552+int
553+libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx);
554+int
555+libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx);
556+/**
557+ * 获取带slot的touches信息, 仅支持LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE
558+ */
559+struct sloted_coords_info *
560+libinput_event_gesture_get_solt_touches(struct libinput_event_gesture *event);
561+
562+/**
563+ * @brief Obtain the device values the EV_LED event type
564+ *
565+ * @param device  A current input device
566+ * @return int Obtained is Supported
567+ */
568+int libinput_has_event_led_type(struct libinput_device *device);
569+
570+/**
571+ * @brief Obtain the function key enablement status of a keyboard device
572+ *
573+ * @param device  A current input device
574+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL,
575+ * given code (see linux/input-event-codes.h).
576+ * @return int Obtained state
577+ */
578+int libinput_get_funckey_state(struct libinput_device *device, unsigned int code);
579+
580+/**
581+ * @brief Turn an LED on or off. Convenience function, if you need to modify multiple
582+ * LEDs simultaneously, use libinput_set_led_state() instead.
583+ *
584+ * @param device  A current input device
585+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL,
586+ * given code (see linux/input-event-codes.h).
587+ * @param state value Specifies whether to turn the LED on or off
588+ * @return int 0 on success, or a negative errno on failure
589+ */
590+int libinput_set_led_state(struct libinput_device *device, unsigned int code, unsigned int state);
591+
592+/**
593  * @defgroup event_tablet Tablet events
594  *
595  * Events that come from tools on tablet devices. For events from the pad,
596@@ -2817,6 +3312,19 @@
597 /**
598  * @ingroup event_tablet
599  *
600+ * Get the stylus event type reported from evdev_tablet
601+ *
602+ * @param event The libinput tablet tool event
603+ * @return Tool type for stylus events
604+ *
605+ * @since 1.2
606+ */
607+int32_t
608+libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event);
609+
610+/**
611+ * @ingroup event_tablet
612+ *
613  * Return the high-level tool type for a tool object.
614  *
615  * The high level tool describes general interaction expected with the tool.
616@@ -3663,6 +4171,56 @@
617 int
618 libinput_dispatch(struct libinput *libinput);
619
620+/****************************************************************************
621+* @brief : brief
622+* @author : fms
623+* @date : 2021/3/8 20:55
624+* @version : ver 1.0
625+* @inparam :libinput  event
626+* @outparam :
627+*****************************************************************************/
628+void
629+libinput_post_handle_event(struct libinput* libinput,
630+	struct libinput_event* event);
631+
632+/****************************************************************************
633+* @brief : get joystick button event
634+* @author : fms
635+* @date : 2021/3/12 10:56
636+* @version : ver 1.0
637+* @inparam :
638+* @outparam :
639+*****************************************************************************/
640+struct libinput_event_joystick_button*
641+libinput_event_get_joystick_button_event(struct libinput_event* event);
642+
643+/****************************************************************************
644+* @brief : get joystick axis event
645+* @author : fms
646+* @date : 2021/3/12 10:56
647+* @version : ver 1.0
648+* @inparam :
649+* @outparam :
650+*****************************************************************************/
651+struct libinput_event_joystick_axis*
652+    libinput_event_get_joystick_axis_event(struct libinput_event* event);
653+/**
654+ * @brief 获取轴事件的时间
655+ */
656+uint64_t
657+libinput_event_get_joystick_axis_time(struct libinput_event_joystick_axis *event);
658+
659+/**
660+ * @brief 获取joystick指定轴的数据是否变化
661+*/
662+int32_t libinput_event_get_joystick_axis_value_is_changed(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis);
663+
664+/**
665+ * @brief 获取joystick指定轴的abs信息
666+*/
667+struct libinput_event_joystick_axis_abs_info *
668+libinput_event_get_joystick_axis_abs_info(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis);
669+
670 /**
671  * @ingroup base
672  *
673@@ -4133,6 +4691,42 @@
674 const char *
675 libinput_device_get_name(struct libinput_device *device);
676
677+/**  @brief   获取设备类型*/
678+enum evdev_device_udev_tags
679+libinput_device_get_tags(struct libinput_device* device);
680+
681+/**  @brief   设备按键能力查询*/
682+int32_t
683+libinput_device_has_key(struct libinput_device* device, int32_t keyCode);
684+
685+/**  @brief   获取设备特定轴的最小值*/
686+int32_t
687+libinput_device_get_axis_min(struct libinput_device* device, int32_t code);
688+
689+/**  @brief   获取设备特定轴的最大值*/
690+int32_t
691+libinput_device_get_axis_max(struct libinput_device* device, int32_t code);
692+
693+/**  @brief   获取设备特定轴的fuzz值*/
694+int32_t
695+libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code);
696+
697+/**  @brief   获取设备特定轴的flat值*/
698+int32_t
699+libinput_device_get_axis_flat(struct libinput_device* device, int32_t code);
700+
701+/**  @brief   获取设备特定轴的resolution值*/
702+int32_t
703+libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code);
704+
705+/**  @brief   获取设备的bustype值*/
706+unsigned int
707+libinput_device_get_id_bustype(struct libinput_device* device);
708+
709+/**  @brief   获取设备的version值*/
710+unsigned int
711+libinput_device_get_id_version(struct libinput_device* device);
712+
713 /**
714  * @ingroup device
715  *
716@@ -4343,6 +4937,12 @@
717 libinput_device_touch_get_touch_count(struct libinput_device *device);
718
719 /**
720+ * @brief 获取触摸屏工具类型按钮是否按下
721+ */
722+int
723+libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType);
724+
725+/**
726  * @ingroup device
727  *
728  * Check if a @ref LIBINPUT_DEVICE_CAP_SWITCH device has a switch of the
729@@ -5722,6 +6322,9 @@
730 enum libinput_config_click_method
731 libinput_device_config_click_get_default_method(struct libinput_device *device);
732
733+uint64_t
734+libinput_event_get_sensortime(struct libinput_event *event);
735+
736 /**
737  * @ingroup config
738  */
739@@ -6398,7 +7001,108 @@
740 unsigned int
741 libinput_device_config_rotation_get_default_angle(struct libinput_device *device);
742
743+/**
744+ * @ingroup event
745+ *
746+ * Get the struct libinput_event_joystick_button from the event.
747+ *
748+ * @param event The libinput event
749+ * @return The libinput_event_joystick_button for this event.
750+ */
751+struct libinput_event_joystick_button*
752+libinput_event_get_joystick_pointer_button_event(struct libinput_event* event);
753+
754+/**
755+ * @ingroup event
756+ *
757+ * Get the time from the event.
758+ *
759+ * @param event The libinput_event_joystick_button
760+ * @return The time for this event.
761+ */
762+uint64_t libinput_event_joystick_button_time(struct libinput_event_joystick_button* event);
763+
764+/**
765+ * @ingroup event
766+ *
767+ * Get the key value from the event.
768+ *
769+ * @param event The libinput_event_joystick_button
770+ * @return The key value for this event.
771+ */
772+uint32_t libinput_event_joystick_button_get_key(struct libinput_event_joystick_button* event);
773+
774+/**
775+ * @ingroup event
776+ *
777+ * Get the seat key count from the event.
778+ *
779+ * @param event The libinput_event_joystick_button
780+ * @return The seat key count for this event.
781+ */
782+uint32_t libinput_event_joystick_button_get_seat_key_count(struct libinput_event_joystick_button* event);
783+
784+/**
785+ * @ingroup event
786+ *
787+ * Get the value count from the event.
788+ *
789+ * @param event The libinput_event_joystick_button
790+ * @return The value for this event.
791+ */
792+int libinput_event_joystick_button_get_value(struct libinput_event_joystick_button* event);
793+
794+/**
795+ * @ingroup config
796+ *
797+ * Get the pressure of the touch screen
798+ *
799+ * @param Carried libinput event
800+ * @return Pressure value of touch screen
801+ *
802+ * @since 1.4
803+ */
804+double
805+libinput_event_touch_get_pressure(struct libinput_event_touch* event);
806+
807+int32_t
808+libinput_event_get_hand_feature(struct libinput_event *event);
809+
810+int32_t
811+libinput_event_touch_get_blob_id(struct libinput_event_touch* event);
812+
813+/**
814+ * @ingroup event_touch
815+ *
816+ * Gets the long axis of the touch point region of the touch screen
817+ *
818+ * @param event The libinput touch event
819+ * @return Long axis value of touch point region
820+ */
821+int32_t
822+libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event);
823+
824+/**
825+ * @ingroup event_touch
826+ *
827+ * Gets the short axis of the touch point region of the touch screen
828+ *
829+ * @param event The libinput touch event
830+ * @return Short axis value of touch point region
831+ */
832+int32_t
833+libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event);
834+
835+const char*
836+libinput_device_get_phys(struct libinput_device* device);
837+
838+const char*
839+libinput_device_get_uniq(struct libinput_device* device);
840+
841+enum libinput_button_state
842+libinput_event_joystick_button_get_key_state(struct libinput_event_joystick_button* event);
843 #ifdef __cplusplus
844 }
845 #endif
846 #endif /* LIBINPUT_H */
847+
848diff -Naur old/hm_src/hm_missing.c new/hm_src/hm_missing.c
849--- old/hm_src/hm_missing.c	1970-01-01 08:00:00.000000000 +0800
850+++ new/hm_src/hm_missing.c	2024-01-01 00:00:00.000000000 +0800
851@@ -0,0 +1,22 @@
852+/*
853+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
854+ * Licensed under the Apache License, Version 2.0 (the "License");
855+ * you may not use this file except in compliance with the License.
856+ * You may obtain a copy of the License at
857+ *
858+ *     http://www.apache.org/licenses/LICENSE-2.0
859+ *
860+ * Unless required by applicable law or agreed to in writing, software
861+ * distributed under the License is distributed on an "AS IS" BASIS,
862+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
863+ * See the License for the specific language governing permissions and
864+ * limitations under the License.
865+ */
866+
867+#include "hm_missing.h"
868+
869+extern char *__progname;
870+char *ohos_program_invocation_short_name()
871+{
872+    return __progname;
873+}
874\ No newline at end of file
875diff -Naur old/hm_src/hm_missing.h new/hm_src/hm_missing.h
876--- old/hm_src/hm_missing.h	1970-01-01 08:00:00.000000000 +0800
877+++ new/hm_src/hm_missing.h	2024-01-01 00:00:00.000000000 +0800
878@@ -0,0 +1,25 @@
879+/*
880+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
881+ * Licensed under the Apache License, Version 2.0 (the "License");
882+ * you may not use this file except in compliance with the License.
883+ * You may obtain a copy of the License at
884+ *
885+ *     http://www.apache.org/licenses/LICENSE-2.0
886+ *
887+ * Unless required by applicable law or agreed to in writing, software
888+ * distributed under the License is distributed on an "AS IS" BASIS,
889+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
890+ * See the License for the specific language governing permissions and
891+ * limitations under the License.
892+ */
893+
894+#ifndef OHOS_LIBINPUT_HM_MISSING_H
895+#define OHOS_LIBINPUT_HM_MISSING_H
896+
897+/* The full and simple forms of the name with which the program was
898+   invoked.  These variables are set up automatically at startup based on
899+   the value of argv[0].  */
900+extern char *ohos_program_invocation_short_name();
901+#define program_invocation_short_name ohos_program_invocation_short_name()
902+
903+#endif
904diff -Naur old/include/linux/freebsd/input-event-codes.h new/include/linux/freebsd/input-event-codes.h
905--- old/include/linux/freebsd/input-event-codes.h	2024-01-01 00:00:00.000000000 +0800
906+++ new/include/linux/freebsd/input-event-codes.h	2024-01-01 00:00:00.000000000 +0800
907@@ -335,7 +335,7 @@
908 #define KEY_WIMAX		KEY_WWAN
909 #define KEY_RFKILL		247	/* Key that controls all radios */
910
911-#define KEY_MICMUTE		248	/* Mute / unmute the microphone */
912+#define KEY_MICMUTE		251	/* Mute / unmute the microphone */
913
914 /* Code 255 is reserved for special needs of AT keyboard driver */
915
916@@ -834,7 +834,7 @@
917 #define ABS_TOOL_WIDTH		0x1c
918
919 #define ABS_VOLUME		0x20
920-
921+#define ABS_HAND_FEATURE 0x21
922 #define ABS_MISC		0x28
923
924 /*
925@@ -889,7 +889,8 @@
926 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
927 #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
928 #define SW_MACHINE_COVER	0x10  /* set = cover closed */
929-#define SW_MAX			0x10
930+#define SW_SUPER_PRIVACY	0x11  /* set = super privacy open */
931+#define SW_MAX			    0x11
932 #define SW_CNT			(SW_MAX+1)
933
934 /*
935diff -Naur old/include/linux/linux/input-event-codes.h new/include/linux/linux/input-event-codes.h
936--- old/include/linux/linux/input-event-codes.h	2024-01-01 00:00:00.000000000 +0800
937+++ new/include/linux/linux/input-event-codes.h	2024-01-01 00:00:00.000000000 +0800
938@@ -335,7 +335,7 @@
939 #define KEY_WIMAX		KEY_WWAN
940 #define KEY_RFKILL		247	/* Key that controls all radios */
941
942-#define KEY_MICMUTE		248	/* Mute / unmute the microphone */
943+#define KEY_MICMUTE		251	/* Mute / unmute the microphone */
944
945 /* Code 255 is reserved for special needs of AT keyboard driver */
946
947@@ -834,7 +834,7 @@
948 #define ABS_TOOL_WIDTH		0x1c
949
950 #define ABS_VOLUME		0x20
951-
952+#define ABS_HAND_FEATURE 0x21
953 #define ABS_MISC		0x28
954
955 /*
956@@ -889,7 +889,8 @@
957 #define SW_MUTE_DEVICE		0x0e  /* set = device disabled */
958 #define SW_PEN_INSERTED		0x0f  /* set = pen inserted */
959 #define SW_MACHINE_COVER	0x10  /* set = cover closed */
960-#define SW_MAX			0x10
961+#define SW_SUPER_PRIVACY	0x11  /* set = super privacy open */
962+#define SW_MAX			    0x11
963 #define SW_CNT			(SW_MAX+1)
964
965 /*
966diff -Naur old/src/evdev.c new/src/evdev.c
967--- old/src/evdev.c	2024-01-01 00:00:00.000000000 +0800
968+++ new/src/evdev.c	2024-01-01 00:00:00.000000000 +0800
969@@ -52,26 +52,6 @@
970 #define DEFAULT_WHEEL_CLICK_ANGLE 15
971 #define DEFAULT_BUTTON_SCROLL_TIMEOUT ms2us(200)
972
973-enum evdev_device_udev_tags {
974-	EVDEV_UDEV_TAG_INPUT		= bit(0),
975-	EVDEV_UDEV_TAG_KEYBOARD		= bit(1),
976-	EVDEV_UDEV_TAG_MOUSE		= bit(2),
977-	EVDEV_UDEV_TAG_TOUCHPAD		= bit(3),
978-	EVDEV_UDEV_TAG_TOUCHSCREEN	= bit(4),
979-	EVDEV_UDEV_TAG_TABLET		= bit(5),
980-	EVDEV_UDEV_TAG_JOYSTICK		= bit(6),
981-	EVDEV_UDEV_TAG_ACCELEROMETER	= bit(7),
982-	EVDEV_UDEV_TAG_TABLET_PAD	= bit(8),
983-	EVDEV_UDEV_TAG_POINTINGSTICK	= bit(9),
984-	EVDEV_UDEV_TAG_TRACKBALL	= bit(10),
985-	EVDEV_UDEV_TAG_SWITCH		= bit(11),
986-};
987-
988-struct evdev_udev_tag_match {
989-	const char *name;
990-	enum evdev_device_udev_tags tag;
991-};
992-
993 static const struct evdev_udev_tag_match evdev_udev_tag_matches[] = {
994 	{"ID_INPUT",			EVDEV_UDEV_TAG_INPUT},
995 	{"ID_INPUT_KEYBOARD",		EVDEV_UDEV_TAG_KEYBOARD},
996@@ -131,7 +111,12 @@
997 {
998 	int key_count = 0;
999 	assert(code >= 0 && code < KEY_CNT);
1000-
1001+	if (code == BTN_LEFT) {
1002+		if (device->key_count[code] == pressed) {
1003+			return pressed;
1004+		}
1005+	}
1006+
1007 	if (pressed) {
1008 		key_count = ++device->key_count[code];
1009 	} else {
1010@@ -209,6 +194,56 @@
1011 }
1012
1013 static void
1014+evdev_pointer_post_button_touchpad(struct evdev_device *device,
1015+			  uint64_t time,
1016+			  unsigned int button,
1017+			  enum libinput_button_state state)
1018+{
1019+	int down_count;
1020+
1021+	down_count = evdev_update_key_down_count(device, button, state);
1022+
1023+	if ((state == LIBINPUT_BUTTON_STATE_PRESSED && down_count == 1) ||
1024+	    (state == LIBINPUT_BUTTON_STATE_RELEASED && down_count == 0)) {
1025+		pointer_notify_button_touchpad(&device->base, time, button, state);
1026+
1027+		if (state == LIBINPUT_BUTTON_STATE_RELEASED) {
1028+			if (device->left_handed.change_to_enabled)
1029+				device->left_handed.change_to_enabled(device);
1030+
1031+			if (device->scroll.change_scroll_method)
1032+				device->scroll.change_scroll_method(device);
1033+		}
1034+	}
1035+
1036+}
1037+
1038+static void
1039+evdev_pointer_post_tap(struct evdev_device *device,
1040+			  uint64_t time,
1041+			  unsigned int button,
1042+			  enum libinput_button_state state)
1043+{
1044+	int down_count;
1045+
1046+	down_count = evdev_update_key_down_count(device, button, state);
1047+
1048+	if ((state == LIBINPUT_BUTTON_STATE_PRESSED && down_count == 1) ||
1049+	    (state == LIBINPUT_BUTTON_STATE_RELEASED && down_count == 0)) {
1050+		pointer_notify_tap(&device->base, time, button, state);
1051+
1052+		if (state == LIBINPUT_BUTTON_STATE_RELEASED) {
1053+			if (device->left_handed.change_to_enabled)
1054+				device->left_handed.change_to_enabled(device);
1055+
1056+			if (device->scroll.change_scroll_method)
1057+				device->scroll.change_scroll_method(device);
1058+		}
1059+	}
1060+
1061+}
1062+
1063+static void
1064 evdev_button_scroll_timeout(uint64_t time, void *data)
1065 {
1066 	struct evdev_device *device = data;
1067@@ -329,6 +364,36 @@
1068 }
1069
1070 void
1071+evdev_pointer_notify_button_touchpad(struct evdev_device *device,
1072+			    uint64_t time,
1073+			    unsigned int button,
1074+			    enum libinput_button_state state)
1075+{
1076+	if (device->scroll.method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN &&
1077+	    button == device->scroll.button) {
1078+		evdev_button_scroll_button(device, time, state);
1079+		return;
1080+	}
1081+
1082+	evdev_pointer_post_button_touchpad(device, time, button, state);
1083+}
1084+
1085+void
1086+evdev_pointer_notify_tap(struct evdev_device *device,
1087+			    uint64_t time,
1088+			    unsigned int button,
1089+			    enum libinput_button_state state)
1090+{
1091+	if (device->scroll.method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN &&
1092+	    button == device->scroll.button) {
1093+		evdev_button_scroll_button(device, time, state);
1094+		return;
1095+	}
1096+
1097+	evdev_pointer_post_tap(device, time, button, state);
1098+}
1099+
1100+void
1101 evdev_device_led_update(struct evdev_device *device, enum libinput_led leds)
1102 {
1103 	static const struct {
1104@@ -369,6 +434,17 @@
1105 }
1106
1107 void
1108+evdev_transform_absolute_rect(struct evdev_device *device,
1109+			 struct device_coord_rect *rect)
1110+{
1111+	if (!device->abs.apply_calibration)
1112+		return;
1113+
1114+	matrix_mult_vec(&device->abs.calibration, &rect->x, &rect->y);
1115+	matrix_mult_vec(&device->abs.calibration, &rect->w, &rect->h);
1116+}
1117+
1118+void
1119 evdev_transform_relative(struct evdev_device *device,
1120 			 struct device_coords *point)
1121 {
1122@@ -384,7 +460,10 @@
1123 static inline double
1124 scale_axis(const struct input_absinfo *absinfo, double val, double to_range)
1125 {
1126-	return (val - absinfo->minimum) * to_range / absinfo_range(absinfo);
1127+    if (absinfo->maximum < absinfo->minimum) {
1128+        return 0.0;
1129+    }
1130+    return (val - absinfo->minimum) * to_range / absinfo_range(absinfo);
1131 }
1132
1133 double
1134@@ -1965,6 +2044,9 @@
1135 	return true;
1136 }
1137
1138+static enum evdev_device_udev_tags
1139+update_device_capability(struct evdev_device *device);
1140+
1141 static struct evdev_dispatch *
1142 evdev_configure_device(struct evdev_device *device)
1143 {
1144@@ -1974,11 +2056,17 @@
1145 	struct evdev_dispatch *dispatch;
1146
1147 	udev_tags = evdev_device_get_udev_tags(device, device->udev_device);
1148+    libinput_log_printf("----evdev_configure_device  tagged as supported input device---- %d \r\n", udev_tags);
1149
1150 	if ((udev_tags & EVDEV_UDEV_TAG_INPUT) == 0 ||
1151 	    (udev_tags & ~EVDEV_UDEV_TAG_INPUT) == 0) {
1152+		udev_tags = update_device_capability(device);
1153+	}
1154+	if ((udev_tags & EVDEV_UDEV_TAG_INPUT) == 0 ||
1155+	    (udev_tags & ~EVDEV_UDEV_TAG_INPUT) == 0) {
1156 		evdev_log_info(device,
1157 			       "not tagged as supported input device\n");
1158+        libinput_log_printf("----evdev_configure_device not tagged as supported input device---- \r\n");
1159 		return NULL;
1160 	}
1161
1162@@ -2029,8 +2117,23 @@
1163 			udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN;
1164 	}
1165
1166+    if (udev_tags & EVDEV_UDEV_TAG_JOYSTICK) {
1167+        libinput_log_printf("----evdev_configure_device--_LIBINPUT_JOYSTICK_BULID-- \r\n");
1168+        dispatch = evdev_joystick_create(device);
1169+        device->seat_caps |= EVDEV_DEVICE_JOYSTICK;
1170+		return dispatch;
1171+    }
1172+	if (udev_tags & EVDEV_UDEV_TAG_SWITCH && libevdev_has_event_code(evdev, EV_SW, SW_SUPER_PRIVACY)) {
1173+		libinput_log_printf("device is a super privacy switch device.\r\n");
1174+		dispatch = evdev_privacy_switch_create(device);
1175+		device->seat_caps |= EVDEV_DEVICE_SWITCH;
1176+		device->tags |= EVDEV_TAG_PRIVACY_SWITCH;
1177+		return dispatch;
1178+	}
1179+
1180 	if (evdev_device_has_model_quirk(device,
1181 					 QUIRK_MODEL_DELL_CANVAS_TOTEM)) {
1182+        libinput_log_printf("----evdev_configure_device--_LIBINPUT_TOTEM_BULID-- \r\n");
1183 		dispatch = evdev_totem_create(device);
1184 		device->seat_caps |= EVDEV_DEVICE_TABLET;
1185 		evdev_log_info(device, "device is a totem\n");
1186@@ -2046,6 +2149,7 @@
1187
1188 	/* libwacom assigns tablet _and_ tablet_pad to the pad devices */
1189 	if (udev_tags & EVDEV_UDEV_TAG_TABLET_PAD) {
1190+	libinput_log_printf("----evdev_configure_device--_LIBINPUT_TABLET_PAD_BULID-- \r\n");
1191 		dispatch = evdev_tablet_pad_create(device);
1192 		device->seat_caps |= EVDEV_DEVICE_TABLET_PAD;
1193 		evdev_log_info(device, "device is a tablet pad\n");
1194@@ -2054,6 +2158,7 @@
1195 	}
1196
1197 	if ((udev_tags & tablet_tags) == EVDEV_UDEV_TAG_TABLET) {
1198+	libinput_log_printf("----evdev_configure_device--_LIBINPUT_TABLET_BULID-- \r\n");
1199 		dispatch = evdev_tablet_create(device);
1200 		device->seat_caps |= EVDEV_DEVICE_TABLET;
1201 		evdev_log_info(device, "device is a tablet\n");
1202@@ -2061,6 +2166,7 @@
1203 	}
1204
1205 	if (udev_tags & EVDEV_UDEV_TAG_TOUCHPAD) {
1206+        libinput_log_printf("----evdev_configure_device--_LIBINPUT_TOUCHPAD_BULID-- \r\n");
1207 		if (udev_tags & EVDEV_UDEV_TAG_TABLET)
1208 			evdev_tag_tablet_touchpad(device);
1209 		/* whether velocity should be averaged, false by default */
1210@@ -2147,6 +2253,10 @@
1211 		return NULL;
1212 	}
1213
1214+	if (udev_tags & EVDEV_UDEV_TAG_MSDP) {
1215+		device->seat_caps |= EVDEV_DEVICE_MSDP;
1216+	}
1217+
1218 	if (evdev_device_has_model_quirk(device, QUIRK_MODEL_INVERT_HORIZONTAL_SCROLLING)) {
1219 		device->scroll.invert_horizontal_scrolling = true;
1220 	}
1221@@ -2518,6 +2628,18 @@
1222 }
1223
1224 unsigned int
1225+evdev_device_get_id_bustype(struct evdev_device *device)
1226+{
1227+	return libevdev_get_id_bustype(device->evdev);
1228+}
1229+
1230+unsigned int
1231+evdev_device_get_id_version(struct evdev_device *device)
1232+{
1233+	return libevdev_get_id_version(device->evdev);
1234+}
1235+
1236+unsigned int
1237 evdev_device_get_id_product(struct evdev_device *device)
1238 {
1239 	return libevdev_get_id_product(device->evdev);
1240@@ -2535,6 +2657,33 @@
1241 	return udev_device_ref(device->udev_device);
1242 }
1243
1244+enum evdev_device_udev_tags
1245+	evdev_device_get_udev_device_tags(struct evdev_device* device)
1246+{
1247+    enum evdev_device_udev_tags udev_tags;
1248+    udev_tags = evdev_device_get_udev_tags(device, device->udev_device);
1249+    return udev_tags;
1250+}
1251+
1252+int
1253+evdev_has_event_type(struct evdev_device *device, unsigned int type)
1254+{
1255+    return libevdev_has_event_type(device->evdev, type);
1256+}
1257+
1258+int
1259+evdev_get_event_value(struct evdev_device *device, unsigned int type, unsigned int code)
1260+{
1261+    return libevdev_get_event_value(device->evdev, type, code);
1262+}
1263+
1264+int
1265+evdev_kernel_set_led_value(struct evdev_device *device, unsigned int code, unsigned int state)
1266+{
1267+    enum libevdev_led_value value = (state == 0 ? LIBEVDEV_LED_OFF : LIBEVDEV_LED_ON);
1268+    return libevdev_kernel_set_led_value(device->evdev, code, value);
1269+}
1270+
1271 void
1272 evdev_device_set_default_calibration(struct evdev_device *device,
1273 				     const float calibration[6])
1274@@ -2702,6 +2851,9 @@
1275 		return !!(device->seat_caps & EVDEV_DEVICE_TABLET_PAD);
1276 	case LIBINPUT_DEVICE_CAP_SWITCH:
1277 		return !!(device->seat_caps & EVDEV_DEVICE_SWITCH);
1278+	case LIBINPUT_DEVICE_CAP_JOYSTICK:
1279+		return !!(device->seat_caps & EVDEV_DEVICE_JOYSTICK);
1280+
1281 	default:
1282 		return false;
1283 	}
1284@@ -2902,10 +3054,9 @@
1285 	if (device->scroll.direction != 0) {
1286 		switch (source) {
1287 		case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
1288-			pointer_notify_axis_finger(&device->base,
1289-						   time,
1290-						   device->scroll.direction,
1291-						   &zero);
1292+			gesture_notify_axis_finger(&device->base, time,
1293+					LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END,
1294+					0, &zero);
1295 			break;
1296 		case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
1297 			pointer_notify_axis_continuous(&device->base,
1298@@ -3163,3 +3314,85 @@
1299 #endif
1300 	return has_left_handed;
1301 }
1302+
1303+static inline bool
1304+is_touchscreen(const struct libevdev *evdev)
1305+{
1306+	return (libevdev_has_event_type(evdev, EV_ABS) &&
1307+			libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X) &&
1308+			libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_Y) &&
1309+			libevdev_has_property(evdev, INPUT_PROP_DIRECT));
1310+}
1311+
1312+static inline bool
1313+is_mouse(const struct libevdev *evdev)
1314+{
1315+	return (libevdev_has_event_type(evdev, EV_REL) &&
1316+			libevdev_has_event_code(evdev, EV_REL, REL_X) &&
1317+			libevdev_has_event_code(evdev, EV_REL, REL_Y));
1318+}
1319+
1320+static inline bool
1321+is_keyboard(const struct libevdev *evdev)
1322+{
1323+	return (libevdev_has_event_type(evdev, EV_KEY) &&
1324+			!libevdev_has_event_type(evdev, EV_ABS) &&
1325+			!libevdev_has_event_type(evdev, EV_REL));
1326+}
1327+
1328+static inline bool
1329+is_touchpad(const struct libevdev *evdev)
1330+{
1331+	return (libevdev_has_event_type(evdev, EV_ABS) &&
1332+			libevdev_has_event_code(evdev, EV_ABS, ABS_MT_POSITION_X));
1333+}
1334+
1335+static inline bool
1336+is_switch(const struct libevdev *evdev)
1337+{
1338+	return (libevdev_has_event_type(evdev, EV_SW));
1339+}
1340+
1341+static inline bool
1342+is_touchhand(const struct libevdev *evdev)
1343+{
1344+	return (libevdev_has_event_type(evdev, EV_ABS) &&
1345+	        libevdev_has_event_code(evdev, EV_ABS, ABS_HAND_FEATURE));
1346+}
1347+
1348+is_tablet_tool(const struct libevdev *evdev)
1349+{
1350+	return (libevdev_has_event_type(evdev, EV_KEY) &&
1351+			(libevdev_has_event_code(evdev, EV_KEY, BTN_TOOL_PEN) ||
1352+			 libevdev_has_event_code(evdev, EV_KEY, BTN_STYLUS)) &&
1353+			libevdev_has_event_type(evdev, EV_ABS) &&
1354+			libevdev_has_event_code(evdev, EV_ABS, ABS_X) &&
1355+			libevdev_has_event_code(evdev, EV_ABS, ABS_Y));
1356+}
1357+
1358+static enum evdev_device_udev_tags
1359+update_device_capability(struct evdev_device *device)
1360+{
1361+	if (is_touchhand(device->evdev)) {
1362+		return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_MSDP);
1363+	}
1364+	if (is_touchscreen(device->evdev)) {
1365+        return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_TOUCHSCREEN);
1366+	}
1367+	if (is_mouse(device->evdev)) {
1368+        return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_MOUSE);
1369+	}
1370+	if (is_keyboard(device->evdev)) {
1371+		return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_KEYBOARD);
1372+	}
1373+	if (is_tablet_tool(device->evdev)) {
1374+		return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_TABLET);
1375+	}
1376+	if (is_touchpad(device->evdev)) {
1377+		return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_TOUCHPAD);
1378+	}
1379+	if (is_switch(device->evdev)) {
1380+		return (EVDEV_UDEV_TAG_INPUT | EVDEV_UDEV_TAG_SWITCH);
1381+	}
1382+    return 0;
1383+}
1384diff -Naur old/src/evdev-fallback.c new/src/evdev-fallback.c
1385--- old/src/evdev-fallback.c	2024-01-01 00:00:00.000000000 +0800
1386+++ new/src/evdev-fallback.c	2024-01-01 00:00:00.000000000 +0800
1387@@ -229,8 +229,11 @@
1388 	struct libinput_device *base = &device->base;
1389 	struct libinput_seat *seat = base->seat;
1390 	struct device_coords point;
1391+	struct device_coord_rect rect;
1392 	struct mt_slot *slot;
1393 	int seat_slot;
1394+	struct touch_axis axis;
1395+	int tool_type;
1396
1397 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
1398 		return false;
1399@@ -253,8 +256,12 @@
1400 	slot->hysteresis_center = point;
1401 	evdev_transform_absolute(device, &point);
1402
1403-	touch_notify_touch_down(base, time, slot_idx, seat_slot,
1404-				&point);
1405+	tool_type = slot->tool_type;
1406+	axis = slot->axis;
1407+	rect = slot->tool_rect;
1408+	evdev_transform_absolute_rect(device, &rect);
1409+	touch_notify_touch_down(base, time, slot_idx, seat_slot, slot->pressure, &slot->extraData,
1410+				&axis, &point, tool_type, &rect);
1411
1412 	return true;
1413 }
1414@@ -267,8 +274,11 @@
1415 {
1416 	struct libinput_device *base = &device->base;
1417 	struct device_coords point;
1418+	struct device_coord_rect rect;
1419 	struct mt_slot *slot;
1420 	int seat_slot;
1421+	struct touch_axis axis;
1422+	int tool_type;
1423
1424 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
1425 		return false;
1426@@ -276,6 +286,7 @@
1427 	slot = &dispatch->mt.slots[slot_idx];
1428 	seat_slot = slot->seat_slot;
1429 	point = slot->point;
1430+    axis = slot->axis;
1431
1432 	if (seat_slot == -1)
1433 		return false;
1434@@ -284,8 +295,12 @@
1435 		return false;
1436
1437 	evdev_transform_absolute(device, &point);
1438-	touch_notify_touch_motion(base, time, slot_idx, seat_slot,
1439-				  &point);
1440+
1441+	tool_type = slot->tool_type;
1442+	rect = slot->tool_rect;
1443+	evdev_transform_absolute_rect(device, &rect);
1444+	touch_notify_touch_motion(base, time, slot_idx, seat_slot, slot->pressure, &slot->extraData,
1445+				  &axis, &point, tool_type, &rect);
1446
1447 	return true;
1448 }
1449@@ -300,6 +315,7 @@
1450 	struct libinput_seat *seat = base->seat;
1451 	struct mt_slot *slot;
1452 	int seat_slot;
1453+	int tool_type;
1454
1455 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
1456 		return false;
1457@@ -313,7 +329,9 @@
1458
1459 	seat->slot_map &= ~bit(seat_slot);
1460
1461-	touch_notify_touch_up(base, time, slot_idx, seat_slot);
1462+	tool_type = slot->tool_type;
1463+
1464+	touch_notify_touch_up(base, time, slot_idx, seat_slot, tool_type);
1465
1466 	return true;
1467 }
1468@@ -354,7 +372,12 @@
1469 	struct libinput_device *base = &device->base;
1470 	struct libinput_seat *seat = base->seat;
1471 	struct device_coords point;
1472+	const struct device_coord_rect rect = { 0 };
1473+	const struct touch_axis axis = { 0 };
1474+	const struct extra_data data = { 0 };
1475 	int seat_slot;
1476+	int tool_type;
1477+	int32_t pressure = dispatch->abs.pressure;
1478
1479 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
1480 		return false;
1481@@ -376,7 +399,9 @@
1482 	point = dispatch->abs.point;
1483 	evdev_transform_absolute(device, &point);
1484
1485-	touch_notify_touch_down(base, time, -1, seat_slot, &point);
1486+	tool_type = -1;
1487+
1488+	touch_notify_touch_down(base, time, -1, seat_slot, pressure, &data, &axis, &point, tool_type, &rect);
1489
1490 	return true;
1491 }
1492@@ -388,7 +413,12 @@
1493 {
1494 	struct libinput_device *base = &device->base;
1495 	struct device_coords point;
1496+	const struct device_coord_rect rect = {0};
1497+	const struct touch_axis axis = { 0 };
1498+	const struct extra_data data = { 0 };
1499 	int seat_slot;
1500+	int tool_type;
1501+	int32_t pressure = dispatch->abs.pressure;
1502
1503 	point = dispatch->abs.point;
1504 	evdev_transform_absolute(device, &point);
1505@@ -398,11 +428,22 @@
1506 	if (seat_slot == -1)
1507 		return false;
1508
1509-	touch_notify_touch_motion(base, time, -1, seat_slot, &point);
1510+	tool_type = -1;
1511+
1512+	touch_notify_touch_motion(base, time, -1, seat_slot, pressure, &data, &axis, &point, tool_type, &rect);
1513
1514 	return true;
1515 }
1516
1517+static void
1518+fallback_flush_msdp_motion(struct fallback_dispatch *dispatch,
1519+			 struct evdev_device *device,
1520+			 uint64_t time)
1521+{
1522+	struct libinput_device *base = &device->base;
1523+	touch_notify_msdp(base, time);
1524+}
1525+
1526 static bool
1527 fallback_flush_st_up(struct fallback_dispatch *dispatch,
1528 		     struct evdev_device *device,
1529@@ -411,6 +452,7 @@
1530 	struct libinput_device *base = &device->base;
1531 	struct libinput_seat *seat = base->seat;
1532 	int seat_slot;
1533+	int tool_type;
1534
1535 	if (!(device->seat_caps & EVDEV_DEVICE_TOUCH))
1536 		return false;
1537@@ -423,7 +465,9 @@
1538
1539 	seat->slot_map &= ~bit(seat_slot);
1540
1541-	touch_notify_touch_up(base, time, -1, seat_slot);
1542+	tool_type = -1;
1543+
1544+	touch_notify_touch_up(base, time, -1, seat_slot, tool_type);
1545
1546 	return true;
1547 }
1548@@ -528,6 +572,14 @@
1549 {
1550 	struct mt_slot *slot = &dispatch->mt.slots[dispatch->mt.slot];
1551
1552+	if (e->code == 0x2a) {
1553+		dispatch->device->sensor_timestamp.seconds = e->value;
1554+		return;
1555+	}
1556+	if (e->code == 0x2b) {
1557+		dispatch->device->sensor_timestamp.microseconds = e->value;
1558+		return;
1559+	}
1560 	if (e->code == ABS_MT_SLOT) {
1561 		if ((size_t)e->value >= dispatch->mt.slots_len) {
1562 			evdev_log_bug_libinput(device,
1563@@ -541,6 +593,11 @@
1564 	}
1565
1566 	switch (e->code) {
1567+	case ABS_MT_BLOB_ID:
1568+		slot->extraData.blob_id = e->value;
1569+		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1570+		slot->dirty = true;
1571+		break;
1572 	case ABS_MT_TRACKING_ID:
1573 		if (e->value >= 0) {
1574 			dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1575@@ -598,6 +655,42 @@
1576 			break;
1577 		}
1578 		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1579+		slot->tool_type = e->value;
1580+		slot->dirty = true;
1581+		break;
1582+	case ABS_MT_PRESSURE:
1583+        slot->pressure = e->value;
1584+		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1585+		slot->dirty = true;
1586+		break;
1587+	case ABS_MT_TOUCH_MAJOR:
1588+        slot->axis.major = e->value;
1589+        dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1590+        slot->dirty = true;
1591+		break;
1592+    case ABS_MT_TOUCH_MINOR:
1593+        slot->axis.minor = e->value;
1594+        dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1595+        slot->dirty = true;
1596+        break;
1597+	case ABS_MT_WIDTH_MAJOR:
1598+		slot->tool_rect.w = e->value;
1599+		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1600+		slot->dirty = true;
1601+		break;
1602+	case ABS_MT_WIDTH_MINOR:
1603+		slot->tool_rect.h = e->value;
1604+		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1605+		slot->dirty = true;
1606+		break;
1607+	case ABS_MT_TOOL_X:
1608+		slot->tool_rect.x = e->value;
1609+		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1610+		slot->dirty = true;
1611+		break;
1612+	case ABS_MT_TOOL_Y:
1613+		slot->tool_rect.y = e->value;
1614+		dispatch->pending_event |= EVDEV_ABSOLUTE_MT;
1615 		slot->dirty = true;
1616 		break;
1617 	}
1618@@ -608,6 +701,11 @@
1619 				 struct evdev_device *device,
1620 				 struct input_event *e)
1621 {
1622+	if (e->code == 0x21) {
1623+		dispatch->device->hand_status.hand_feature = e->value;
1624+		dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION;
1625+		return;
1626+	}
1627 	switch (e->code) {
1628 	case ABS_X:
1629 		evdev_device_check_abs_axis_range(device, e->code, e->value);
1630@@ -619,6 +717,10 @@
1631 		dispatch->abs.point.y = e->value;
1632 		dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION;
1633 		break;
1634+	case ABS_PRESSURE:
1635+		dispatch->abs.pressure = e->value;
1636+		dispatch->pending_event |= EVDEV_ABSOLUTE_MOTION;
1637+		break;
1638 	}
1639 }
1640
1641@@ -920,6 +1022,10 @@
1642 			fallback_flush_absolute_motion(dispatch,
1643 						       device,
1644 						       time);
1645+		} else if (device->seat_caps & EVDEV_DEVICE_MSDP) {
1646+			fallback_flush_msdp_motion(dispatch,
1647+								device,
1648+								time);
1649 		}
1650 	}
1651
1652@@ -1556,6 +1662,7 @@
1653
1654 	for (slot = 0; slot < num_slots; ++slot) {
1655 		slots[slot].seat_slot = -1;
1656+		slots[slot].tool_type = -1;
1657
1658 		if (evdev_need_mtdev(device))
1659 			continue;
1660@@ -1718,3 +1825,11 @@
1661
1662 	return &dispatch->base;
1663 }
1664+
1665+bool
1666+evdev_device_touch_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType)
1667+{
1668+	struct fallback_dispatch *dispatch = fallback_dispatch(device->dispatch);
1669+
1670+	return hw_is_key_down(dispatch, btnToolType);
1671+}
1672diff -Naur old/src/evdev-fallback.h new/src/evdev-fallback.h
1673--- old/src/evdev-fallback.h	2024-01-01 00:00:00.000000000 +0800
1674+++ new/src/evdev-fallback.h	2024-01-01 00:00:00.000000000 +0800
1675@@ -75,11 +75,16 @@
1676
1677 struct mt_slot {
1678 	bool dirty;
1679+	struct extra_data extraData;
1680 	enum mt_slot_state state;
1681 	int32_t seat_slot;
1682 	struct device_coords point;
1683 	struct device_coords hysteresis_center;
1684 	enum palm_state palm_state;
1685+	struct device_coord_rect tool_rect;
1686+	int32_t pressure;
1687+	struct touch_axis axis;
1688+	int32_t tool_type;
1689 };
1690
1691 struct fallback_dispatch {
1692@@ -97,6 +102,7 @@
1693 	struct {
1694 		struct device_coords point;
1695 		int32_t seat_slot;
1696+		int32_t pressure;
1697 	} abs;
1698
1699 	struct {
1700@@ -191,6 +197,8 @@
1701 static inline enum key_type
1702 get_key_type(uint16_t code)
1703 {
1704+	const uint16_t KEY_ENDCALL = 0x2e8;
1705+	const uint16_t KEY_FUNCTION = 0x2fe;
1706 	switch (code) {
1707 	case BTN_TOOL_PEN:
1708 	case BTN_TOOL_RUBBER:
1709@@ -220,6 +228,8 @@
1710 		return KEY_TYPE_KEY;
1711 	if (code >= BTN_TRIGGER_HAPPY && code <= BTN_TRIGGER_HAPPY40)
1712 		return KEY_TYPE_BUTTON;
1713+	if (code == KEY_ENDCALL || code == KEY_FUNCTION)
1714+		return KEY_TYPE_KEY;
1715 	return KEY_TYPE_NONE;
1716 }
1717
1718diff -Naur old/src/evdev.h new/src/evdev.h
1719--- old/src/evdev.h	2024-01-01 00:00:00.000000000 +0800
1720+++ new/src/evdev.h	2024-01-01 00:00:00.000000000 +0800
1721@@ -61,6 +61,8 @@
1722 	EVDEV_DEVICE_TABLET_PAD		= bit(4),
1723 	EVDEV_DEVICE_GESTURE		= bit(5),
1724 	EVDEV_DEVICE_SWITCH		= bit(6),
1725+	EVDEV_DEVICE_JOYSTICK = bit(7),
1726+	EVDEV_DEVICE_MSDP		= bit(8),
1727 };
1728
1729 enum evdev_device_tags {
1730@@ -74,6 +76,12 @@
1731 	EVDEV_TAG_EXTERNAL_KEYBOARD	= bit(7),
1732 	EVDEV_TAG_TABLET_MODE_SWITCH	= bit(8),
1733 	EVDEV_TAG_TABLET_TOUCHPAD	= bit(9),
1734+	EVDEV_TAG_PRIVACY_SWITCH	=bit(10),
1735+};
1736+
1737+struct evdev_udev_tag_match {
1738+    const char* name;
1739+    enum evdev_device_udev_tags tag;
1740 };
1741
1742 enum evdev_middlebutton_state {
1743@@ -177,6 +185,7 @@
1744 	enum evdev_device_tags tags;
1745 	bool is_mt;
1746 	bool is_suspended;
1747+	int32_t pressureMax;
1748 	int dpi; /* HW resolution */
1749 	double trackpoint_multiplier; /* trackpoint constant multiplier */
1750 	bool use_velocity_averaging; /* whether averaging should be applied on velocity calculation */
1751@@ -271,6 +280,15 @@
1752 		uint32_t button_mask;
1753 		uint64_t first_event_time;
1754 	} middlebutton;
1755+
1756+	struct {
1757+		int32_t seconds;
1758+		int32_t microseconds;
1759+	} sensor_timestamp;
1760+
1761+	struct {
1762+		int32_t hand_feature;
1763+	} hand_status;
1764 };
1765
1766 static inline struct evdev_device *
1767@@ -354,6 +372,8 @@
1768 	DISPATCH_TABLET,
1769 	DISPATCH_TABLET_PAD,
1770 	DISPATCH_TOTEM,
1771+	DISPATCH_JOYSTICK,
1772+	DISPATCH_PRIVACY_SWITCH,
1773 };
1774
1775 struct evdev_dispatch {
1776@@ -407,6 +427,10 @@
1777 			 struct device_coords *point);
1778
1779 void
1780+evdev_transform_absolute_rect(struct evdev_device *device,
1781+			 struct device_coord_rect *rect);
1782+
1783+void
1784 evdev_transform_relative(struct evdev_device *device,
1785 			 struct device_coords *point);
1786
1787@@ -431,12 +455,21 @@
1788 evdev_device_init_pointer_acceleration(struct evdev_device *device,
1789 				       struct motion_filter *filter);
1790
1791+struct evdev_dispatch*
1792+evdev_joystick_create(struct evdev_device* device);
1793+
1794+struct evdev_dispatch*
1795+evdev_privacy_switch_create(struct evdev_device* device);
1796+
1797 struct evdev_dispatch *
1798 evdev_touchpad_create(struct evdev_device *device);
1799
1800 struct evdev_dispatch *
1801 evdev_mt_touchpad_create(struct evdev_device *device);
1802
1803+bool
1804+evdev_device_touchpad_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType);
1805+
1806 struct evdev_dispatch *
1807 evdev_tablet_create(struct evdev_device *device);
1808
1809@@ -474,6 +507,12 @@
1810 evdev_device_get_name(struct evdev_device *device);
1811
1812 unsigned int
1813+evdev_device_get_id_bustype(struct evdev_device *device);
1814+
1815+unsigned int
1816+evdev_device_get_id_version(struct evdev_device *device);
1817+
1818+unsigned int
1819 evdev_device_get_id_product(struct evdev_device *device);
1820
1821 unsigned int
1822@@ -482,6 +521,19 @@
1823 struct udev_device *
1824 evdev_device_get_udev_device(struct evdev_device *device);
1825
1826+/**  @brief   获取设备类型 */
1827+enum evdev_device_udev_tags
1828+evdev_device_get_udev_device_tags(struct evdev_device* device);
1829+
1830+int
1831+evdev_has_event_type(struct evdev_device *device, unsigned int type);
1832+
1833+int
1834+evdev_get_event_value(struct evdev_device *device, unsigned int type, unsigned int code);
1835+
1836+int
1837+evdev_kernel_set_led_value(struct evdev_device *device, unsigned int code, unsigned int state);
1838+
1839 void
1840 evdev_device_set_default_calibration(struct evdev_device *device,
1841 				     const float calibration[6]);
1842@@ -507,6 +559,9 @@
1843 int
1844 evdev_device_get_touch_count(struct evdev_device *device);
1845
1846+bool
1847+evdev_device_touch_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType);
1848+
1849 int
1850 evdev_device_has_switch(struct evdev_device *device,
1851 			enum libinput_switch sw);
1852@@ -561,6 +616,19 @@
1853 			    uint64_t time,
1854 			    unsigned int button,
1855 			    enum libinput_button_state state);
1856+
1857+void
1858+evdev_pointer_notify_button_touchpad(struct evdev_device *device,
1859+			    uint64_t time,
1860+			    unsigned int button,
1861+			    enum libinput_button_state state);
1862+
1863+void
1864+evdev_pointer_notify_tap(struct evdev_device *device,
1865+			    uint64_t time,
1866+			    unsigned int button,
1867+			    enum libinput_button_state state);
1868+
1869 void
1870 evdev_pointer_notify_physical_button(struct evdev_device *device,
1871 				     uint64_t time,
1872@@ -646,6 +714,9 @@
1873 static inline double
1874 evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
1875 {
1876+	if (absinfo->resolution  == 0){
1877+	    return 0.0;
1878+	}
1879 	double value = v - absinfo->minimum;
1880 	return value/absinfo->resolution;
1881 }
1882@@ -781,12 +852,15 @@
1883
1884 	if (!is_logged(evdev_libinput_context(device), priority))
1885 		return;
1886-
1887+        const char *name = evdev_device_get_sysname(device);
1888+        if (strchr(name, '%') != NULL) {
1889+                return;
1890+        }
1891 	/* Anything info and above is user-visible, use the device name */
1892 	snprintf(buf,
1893 		 sizeof(buf),
1894 		 "%-7s - %s%s%s",
1895-		 evdev_device_get_sysname(device),
1896+		 name,
1897 		 (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ?  device->log_prefix_name : "",
1898 		 (priority > LIBINPUT_LOG_PRIORITY_DEBUG) ?  ": " : "",
1899 		 format);
1900@@ -1028,7 +1102,8 @@
1901 				   "Axis %#x value %d is outside expected range [%d, %d]\n"
1902 				   "See %s/absolute_coordinate_ranges.html for details\n",
1903 				   code, value, min, max,
1904-				   HTTP_DOC_LINK);
1905+				   "");
1906+				//HTTP_DOC_LINK);
1907 	}
1908 }
1909
1910diff -Naur old/src/evdev-joystick.c new/src/evdev-joystick.c
1911--- old/src/evdev-joystick.c	1970-01-01 08:00:00.000000000 +0800
1912+++ new/src/evdev-joystick.c	2024-01-01 00:00:00.000000000 +0800
1913@@ -0,0 +1,590 @@
1914+/*
1915+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
1916+ * Licensed under the Apache License, Version 2.0 (the "License");
1917+ * you may not use this file except in compliance with the License.
1918+ * You may obtain a copy of the License at
1919+ *
1920+ *     http://www.apache.org/licenses/LICENSE-2.0
1921+ *
1922+ * Unless required by applicable law or agreed to in writing, software
1923+ * distributed under the License is distributed on an "AS IS" BASIS,
1924+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1925+ * See the License for the specific language governing permissions and
1926+ * limitations under the License.
1927+ */
1928+
1929+#include <stdbool.h>
1930+#include <string.h>
1931+
1932+#include "config.h"
1933+#include "libinput-version.h"
1934+#include "evdev-joystick.h"
1935+#include "libinput.h"
1936+#include "libinput-util.h"
1937+
1938+static inline struct
1939+joystick_dispatch* get_joystick_dispatch(struct evdev_dispatch* dispatch)
1940+{
1941+    if (dispatch == NULL) {
1942+        return NULL;
1943+    }
1944+    evdev_verify_dispatch_type(dispatch, DISPATCH_JOYSTICK);
1945+
1946+    struct joystick_dispatch* joystick_dispatch = NULL;
1947+    joystick_dispatch = container_of(dispatch, struct joystick_dispatch, base);
1948+
1949+    return joystick_dispatch;
1950+}
1951+
1952+static int
1953+update_seat_joystick_button_count(struct libinput_seat* seat, int32_t key, uint32_t *seat_count, enum libinput_button_state state)
1954+{
1955+    if (seat == NULL || seat_count == NULL || key < SYN_REPORT || key > KEY_MAX) {
1956+        return false;
1957+    }
1958+
1959+    switch (state) {
1960+        case LIBINPUT_BUTTON_STATE_PRESSED:
1961+        {
1962+            *(seat_count) = ++seat->button_count[key];
1963+            break;
1964+        }
1965+        case LIBINPUT_BUTTON_STATE_RELEASED:
1966+        {
1967+            if (seat->button_count[key] == 0)
1968+            {
1969+                *(seat_count) = seat->button_count[key];
1970+            }
1971+            else
1972+            {
1973+                *(seat_count) = --seat->button_count[key];
1974+            }
1975+            break;
1976+        }
1977+        default:
1978+        {
1979+            *(seat_count) = 0;
1980+            break;
1981+        }
1982+    }
1983+    return true;
1984+}
1985+
1986+static void
1987+joystick_notify_axis(struct evdev_device* device, uint64_t time)
1988+{
1989+    if (device == NULL) {
1990+        return;
1991+    }
1992+
1993+	struct joystick_dispatch *joystick_dispatch = get_joystick_dispatch(device->dispatch);
1994+	if (joystick_dispatch == NULL) {
1995+        libinput_log_printf("joystick_dispatch is NULL.\n");
1996+		return;
1997+	}
1998+
1999+    struct libinput_event_joystick_axis* joystick_axis_event = zalloc(sizeof * joystick_axis_event);
2000+    if (joystick_axis_event == NULL) {
2001+        libinput_log_printf("pJoystickEvent is NULL.\n");
2002+        return;
2003+    }
2004+
2005+    *joystick_axis_event = (struct libinput_event_joystick_axis) {
2006+	    .base.type = LIBINPUT_EVENT_POINTER_AXIS,
2007+	    .base.device = &device->base,
2008+        .type = EV_ABS,
2009+        .time = time,
2010+        .axis_value_mask = joystick_dispatch->axis_value_mask,
2011+	    .abs_throttle = joystick_dispatch->axis_abs_infos.abs_throttle,
2012+	    .abs_hat0x = joystick_dispatch->axis_abs_infos.abs_hat0x,
2013+	    .abs_hat0y = joystick_dispatch->axis_abs_infos.abs_hat0y,
2014+	    .abs_x = joystick_dispatch->axis_abs_infos.abs_x,
2015+		.abs_y = joystick_dispatch->axis_abs_infos.abs_y,
2016+		.abs_z = joystick_dispatch->axis_abs_infos.abs_z,
2017+		.abs_rx = joystick_dispatch->axis_abs_infos.abs_rx,
2018+		.abs_ry = joystick_dispatch->axis_abs_infos.abs_ry,
2019+		.abs_rz = joystick_dispatch->axis_abs_infos.abs_rz,
2020+    };
2021+
2022+    struct libinput_event_listener* listener = NULL;
2023+    list_for_each_safe(listener, &device->base.event_listeners, link) {
2024+        listener->notify_func(time, &joystick_axis_event->base, listener->notify_func_data);
2025+    }
2026+
2027+    libinput_post_handle_event(device->base.seat->libinput, &joystick_axis_event->base);
2028+}
2029+
2030+static void
2031+joystick_notify_key_event(struct evdev_device* device, struct input_event* event, uint64_t time)
2032+{
2033+    if (device == NULL || event == NULL) {
2034+        return;
2035+    }
2036+
2037+    struct libinput_event_joystick_button* button_event = {0};
2038+    uint32_t seat_count = 0;
2039+
2040+    int ret = update_seat_joystick_button_count(device->base.seat, event->code, &seat_count, event->value);
2041+    if (ret == 0) {
2042+        return;
2043+    }
2044+
2045+    button_event = zalloc(sizeof * button_event);
2046+    if (button_event == NULL) {
2047+        return;
2048+    }
2049+
2050+	*button_event = (struct libinput_event_joystick_button) {
2051+			.base.type = LIBINPUT_EVENT_JOYSTICK_BUTTON,
2052+			.base.device = &device->base,
2053+            .time = time,
2054+            .type = event->type,
2055+            .key = event->code,
2056+            .value = event->value,
2057+            .seat_key_count = seat_count,
2058+            .state = event->value,
2059+    };
2060+
2061+    struct libinput_event_listener* listener = NULL;
2062+    list_for_each_safe(listener, &device->base.event_listeners, link)
2063+    {
2064+        listener->notify_func(time, &button_event->base, listener->notify_func_data);
2065+    }
2066+
2067+    libinput_post_handle_event(device->base.seat->libinput, &button_event->base);
2068+}
2069+
2070+static float
2071+abs_value_standardize(int32_t value, int32_t minimum, int32_t maximum, float standard_min, float standard_max)
2072+{
2073+    return standard_min + ((float)value - (float)minimum) * ((float)(standard_max - standard_min)) / ((float)(maximum - minimum));
2074+}
2075+
2076+static float
2077+get_joystick_abs_standard_value(struct libinput_event_joystick_axis_abs_info *absinfo)
2078+{
2079+    const int32_t value = absinfo->value;
2080+    const int32_t minimum = absinfo->minimum;
2081+    const int32_t maximum = absinfo->maximum;
2082+    if (minimum >= maximum) {
2083+		libinput_log_printf("joystick abs: minimum(%u) >= maximum(%u).\n", minimum, maximum);
2084+        return 0.f;
2085+    } else if (value < minimum || value > maximum) {
2086+		libinput_log_printf("joystick abs: value(%d) not between minimum(%u) and maximum(%u).\n", value, minimum, maximum);
2087+		return 0.f;
2088+    }
2089+
2090+    const int32_t code = absinfo->code;
2091+    switch (code) {
2092+	case ABS_THROTTLE:
2093+	{
2094+		return abs_value_standardize(value, minimum, maximum, 0, 1.0);
2095+	}
2096+	case ABS_X:
2097+	case ABS_Y:
2098+	case ABS_Z:
2099+	case ABS_RX:
2100+	case ABS_RY:
2101+	case ABS_RZ:
2102+    {
2103+        return abs_value_standardize(value, minimum, maximum, -1.0, 1.0);
2104+	}
2105+    case ABS_HAT0X:
2106+    case ABS_HAT0Y:
2107+    {
2108+        return (float)value;
2109+    }
2110+    default:
2111+    return (float)value;
2112+    }
2113+}
2114+
2115+static void joystick_set_axis_value_mask(struct joystick_dispatch *joystick_dispatch, enum libinput_joystick_axis_source axis)
2116+{
2117+    joystick_dispatch->axis_value_mask |= (uint32_t)axis;
2118+}
2119+
2120+static void joystick_reset_axis_value_mask(struct joystick_dispatch *joystick_dispatch)
2121+{
2122+	joystick_dispatch->axis_value_mask = 0;
2123+}
2124+
2125+static bool joystick_is_axis_value_mask(struct joystick_dispatch *joystick_dispatch)
2126+{
2127+	return (joystick_dispatch->axis_value_mask != 0);
2128+}
2129+
2130+static void joystick_get_one_abs_info(struct joystick_dispatch *joystick_dispatch, struct evdev_device *device, struct input_event *event,
2131+    const uint32_t code)
2132+{
2133+    struct libinput_event_joystick_axis_abs_info *absinfo = NULL;
2134+    switch (code) {
2135+    case ABS_THROTTLE:
2136+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE);
2137+    absinfo = &joystick_dispatch->axis_abs_infos.abs_throttle;
2138+    break;
2139+    case ABS_HAT0X:
2140+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X);
2141+    absinfo = &joystick_dispatch->axis_abs_infos.abs_hat0x;
2142+    break;
2143+    case ABS_HAT0Y:
2144+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y);
2145+    absinfo = &joystick_dispatch->axis_abs_infos.abs_hat0y;
2146+    break;
2147+    case ABS_X:
2148+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X);
2149+    absinfo = &joystick_dispatch->axis_abs_infos.abs_x;
2150+    break;
2151+    case ABS_Y:
2152+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y);
2153+    absinfo = &joystick_dispatch->axis_abs_infos.abs_y;
2154+    break;
2155+	case ABS_Z:
2156+	joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z);
2157+	absinfo = &joystick_dispatch->axis_abs_infos.abs_z;
2158+    break;
2159+	case ABS_RX:
2160+	joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX);
2161+	absinfo = &joystick_dispatch->axis_abs_infos.abs_rx;
2162+	break;
2163+	case ABS_RY:
2164+	joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY);
2165+	absinfo = &joystick_dispatch->axis_abs_infos.abs_ry;
2166+	break;
2167+    case ABS_RZ:
2168+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ);
2169+    absinfo = &joystick_dispatch->axis_abs_infos.abs_rz;
2170+    break;
2171+    case ABS_GAS:
2172+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS);
2173+    absinfo = &joystick_dispatch->axis_abs_infos.abs_gas;
2174+    break;
2175+    case ABS_BRAKE:
2176+    joystick_set_axis_value_mask(joystick_dispatch, LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE);
2177+    absinfo = &joystick_dispatch->axis_abs_infos.abs_brake;
2178+    break;
2179+    default:
2180+    break;
2181+    }
2182+
2183+    if (absinfo == NULL) {
2184+        libinput_log_printf("unsupported joystick abs event: device_name:%s code:%d value:%d.\n",
2185+            device->devname, code, event->value);
2186+        return;
2187+    }
2188+
2189+    struct libevdev *evdev = device->evdev;
2190+    evdev_device_check_abs_axis_range(device, event->code, event->value);
2191+    const struct input_absinfo *absinfo_raw = libevdev_get_abs_info(evdev, event->code);
2192+    absinfo->code = event->code;
2193+    absinfo->value = event->value;
2194+    absinfo->minimum = absinfo_raw->minimum;
2195+    absinfo->maximum = absinfo_raw->maximum;
2196+    absinfo->fuzz = absinfo_raw->fuzz;
2197+    absinfo->flat = absinfo_raw->flat;
2198+    absinfo->resolution = absinfo_raw->resolution;
2199+    absinfo->standardValue = get_joystick_abs_standard_value(absinfo);
2200+}
2201+
2202+static void
2203+joystick_notify_absolute_event(struct joystick_dispatch* pJoystick,
2204+    struct evdev_device* device, struct input_event* event, uint64_t time)
2205+{
2206+    if (pJoystick == NULL || device == NULL || event == NULL) {
2207+        return;
2208+    }
2209+
2210+    joystick_get_one_abs_info(pJoystick, device, event, event->code);
2211+}
2212+
2213+static void
2214+joystick_flush(struct joystick_dispatch* joystick_dispatch, struct evdev_device* device, uint64_t time)
2215+{
2216+    if (joystick_dispatch == NULL || device == NULL) {
2217+        return;
2218+    }
2219+
2220+    if (joystick_dispatch->axis_value_mask != 0) {
2221+        joysticks_notify_axis(&device->base, time, joystick_dispatch->axis_value_mask,
2222+            &joystick_dispatch->axis_abs_infos);
2223+        joystick_reset_axis_value_mask(joystick_dispatch);
2224+    }
2225+}
2226+
2227+static void
2228+joystick_process(struct evdev_dispatch* dispatch, struct evdev_device* device,
2229+    struct input_event* event, uint64_t time)
2230+{
2231+    if (dispatch == NULL || device == NULL || event == NULL) {
2232+        return;
2233+    }
2234+
2235+    struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(dispatch);
2236+    if (joystick_dispatch == NULL) {
2237+        return;
2238+    }
2239+
2240+    switch (event->type) {
2241+    case EV_ABS: {
2242+        joystick_notify_absolute_event(joystick_dispatch, device, event, time);
2243+    }
2244+    break;
2245+    case EV_KEY: {
2246+        joystick_notify_key_event(device, event, time);
2247+    }
2248+    break;
2249+    case EV_SYN: {
2250+        joystick_flush(joystick_dispatch, device, time);
2251+    }
2252+    break;
2253+    case EV_MSC:
2254+    /* ignore do not process */
2255+    break;
2256+    case EV_REL:
2257+    case EV_SW:
2258+    case EV_LED:
2259+    case EV_SND:
2260+    case EV_REP:
2261+    case EV_FF:
2262+    case EV_PWR:
2263+    case EV_FF_STATUS:
2264+    case EV_MAX:
2265+    case EV_CNT:
2266+    default:
2267+        libinput_log_printf("unsupported joystick event type: %d, devname: %s.\n", event->type, device->devname);
2268+    break;
2269+    }
2270+}
2271+
2272+static void joystick_suspend(struct evdev_dispatch* dispatch, struct evdev_device* device)
2273+{
2274+    if (dispatch == NULL || device == NULL) {
2275+        return;
2276+    }
2277+    struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(dispatch);
2278+    if (joystick_dispatch == NULL) {
2279+        return;
2280+    }
2281+   joystick_flush(joystick_dispatch, device, 0);
2282+}
2283+
2284+static void
2285+joystick_destroy(struct evdev_dispatch* dispatch)
2286+{
2287+    if (dispatch == NULL) {
2288+        return;
2289+    }
2290+    struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(dispatch);
2291+    if (dispatch == NULL) {
2292+        return;
2293+    }
2294+
2295+    free(joystick_dispatch);
2296+}
2297+
2298+static void
2299+joystick_device_added(struct evdev_device* device,
2300+    struct evdev_device* added_device)
2301+{
2302+    if (device == NULL || added_device == NULL) {
2303+        return;
2304+    }
2305+    struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(device->dispatch);
2306+    if (joystick_dispatch == NULL) {
2307+        return;
2308+    }
2309+
2310+    bool is_joystick = false;
2311+    if (libinput_device_get_device_group(&device->base) !=
2312+        libinput_device_get_device_group(&added_device->base)) {
2313+        return;
2314+    }
2315+    is_joystick = evdev_device_has_capability(added_device,
2316+        LIBINPUT_DEVICE_CAP_JOYSTICK);
2317+
2318+    if (is_joystick) {
2319+        evdev_log_debug(device,
2320+            "joystick: activated for %s<->%s\n",
2321+            device->devname,
2322+            added_device->devname);
2323+        joystick_dispatch->device = added_device;
2324+    }
2325+}
2326+
2327+static void
2328+joystick_device_removed(struct evdev_device* device,
2329+    struct evdev_device* removed_device)
2330+{
2331+    if (device == NULL || removed_device == NULL) {
2332+        return;
2333+    }
2334+    struct joystick_dispatch* joystick_dispatch = get_joystick_dispatch(device->dispatch);
2335+    if (joystick_dispatch == NULL) {
2336+        return;
2337+    }
2338+
2339+    if (joystick_dispatch->device == removed_device) {
2340+        joystick_dispatch->device = NULL;
2341+    }
2342+}
2343+
2344+static struct evdev_dispatch_interface joystick_interface = {
2345+    .process = joystick_process,
2346+    .suspend = joystick_suspend,
2347+    .remove = NULL,
2348+    .destroy = joystick_destroy,
2349+    .device_added = joystick_device_added,
2350+    .device_removed = joystick_device_removed,
2351+    .device_suspended = NULL,
2352+    .device_resumed = NULL,
2353+    .post_added = NULL,
2354+    .touch_arbitration_toggle = NULL,
2355+    .touch_arbitration_update_rect = NULL,
2356+    .get_switch_state = NULL,
2357+};
2358+
2359+static enum libinput_config_status
2360+joystick_sendevents_set_mode(struct libinput_device* device,
2361+    enum libinput_config_send_events_mode mode)
2362+{
2363+    if (device == NULL)     {
2364+        return LIBINPUT_CONFIG_STATUS_INVALID;
2365+    }
2366+
2367+    struct evdev_device* ev_device = evdev_device(device);
2368+    struct joystick_dispatch* joystick_dispatch = (struct joystick_dispatch*)ev_device->dispatch;
2369+
2370+    if (ev_device == NULL || joystick_dispatch == NULL) {
2371+        return LIBINPUT_CONFIG_STATUS_INVALID;
2372+    }
2373+
2374+    if (mode == joystick_dispatch->sendevents.current_mode) {
2375+        return LIBINPUT_CONFIG_STATUS_SUCCESS;
2376+    }
2377+
2378+    switch (mode) {
2379+    case LIBINPUT_CONFIG_SEND_EVENTS_ENABLED:
2380+        break;
2381+    case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
2382+        joystick_suspend(ev_device->dispatch, ev_device);
2383+        break;
2384+    default:
2385+        return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
2386+    }
2387+
2388+    joystick_dispatch->sendevents.current_mode = mode;
2389+
2390+    return LIBINPUT_CONFIG_STATUS_SUCCESS;
2391+}
2392+
2393+static uint32_t
2394+joystick_sendevents_get_modes(struct libinput_device* device)
2395+{
2396+    return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
2397+}
2398+
2399+static enum libinput_config_send_events_mode
2400+joystick_sendevents_get_mode(struct libinput_device* device)
2401+{
2402+    if (device == NULL) {
2403+        return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
2404+    }
2405+
2406+    struct evdev_device* ev_device = evdev_device(device);
2407+    struct joystick_dispatch* pDispatch = (struct joystick_dispatch*)ev_device->dispatch;
2408+
2409+    if (ev_device == NULL || pDispatch == NULL) {
2410+        return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
2411+    }
2412+
2413+    return pDispatch->sendevents.current_mode;
2414+}
2415+
2416+static enum libinput_config_send_events_mode
2417+joystick_sendevents_get_default_mode(struct libinput_device* device)
2418+{
2419+    return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
2420+}
2421+
2422+#ifdef _DEBUG
2423+void printf_joystick_absinfo(const char *abs_name, struct libinput_event_joystick_axis_abs_info *absinfo)
2424+{
2425+    printf("%s: code: %d, value: %d, minimum: %d, maximum: %d, fuzz: %d, flat: %d, resolution: %d, standardValue: %f\n",
2426+        abs_name,
2427+        absinfo->code,
2428+        absinfo->value,
2429+        absinfo->minimum,
2430+        absinfo->maximum,
2431+        absinfo->fuzz,
2432+        absinfo->flat,
2433+        absinfo->resolution,
2434+        absinfo->standardValue
2435+        );
2436+}
2437+
2438+void print_libinput_event_joystick_axis(struct libinput_event_joystick_axis *p)
2439+{
2440+    printf("JOYSTICK:\n"
2441+        "type: %d, device: %p, type: %d, time: 0x%x\n",
2442+        p->base.type,
2443+        p->base.device,
2444+        p->type,
2445+        p->time);
2446+    printf_joystick_absinfo("abs_throttle", &p->abs_throttle);
2447+    printf_joystick_absinfo("abs_hat0x", &p->abs_hat0x);
2448+    printf_joystick_absinfo("abs_hat0y", &p->abs_hat0y);
2449+    printf_joystick_absinfo("abs_x", &p->abs_x);
2450+	printf_joystick_absinfo("abs_y", &p->abs_y);
2451+	printf_joystick_absinfo("abs_z", &p->abs_z);
2452+	printf_joystick_absinfo("abs_rx", &p->abs_rx);
2453+	printf_joystick_absinfo("abs_ry", &p->abs_ry);
2454+    printf_joystick_absinfo("abs_rz", &p->abs_rz);
2455+}
2456+#endif // _DEBUG
2457+
2458+/**
2459+ * @brief 初始化joystick_dispatch
2460+ * @param joystick
2461+ * @param device
2462+ * @return bool true - 成功, false - 失败
2463+*/
2464+bool
2465+joystick_init(struct joystick_dispatch* pJoystick, struct evdev_device* device)
2466+{
2467+    if (pJoystick == NULL || device == NULL) {
2468+        return false;
2469+    }
2470+
2471+    pJoystick->base.dispatch_type = DISPATCH_JOYSTICK;
2472+    pJoystick->base.interface = &joystick_interface;
2473+    pJoystick->device = device;
2474+
2475+    return true;
2476+}
2477+
2478+struct evdev_dispatch*
2479+evdev_joystick_create(struct evdev_device* device)
2480+{
2481+    if (device == NULL) {
2482+        return NULL;
2483+    }
2484+
2485+    struct joystick_dispatch* joystick = {0};
2486+    joystick = zalloc(sizeof * joystick);
2487+
2488+    if (joystick_init(joystick, device) != true) {
2489+        joystick_destroy(&joystick->base);
2490+        joystick = NULL;
2491+        return NULL;
2492+    }
2493+
2494+    device->base.config.sendevents = &joystick->sendevents.config;
2495+    joystick->sendevents.current_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
2496+    joystick->sendevents.config.get_modes = joystick_sendevents_get_modes;
2497+    joystick->sendevents.config.set_mode = joystick_sendevents_set_mode;
2498+    joystick->sendevents.config.get_mode = joystick_sendevents_get_mode;
2499+    joystick->sendevents.config.get_default_mode = joystick_sendevents_get_default_mode;
2500+
2501+    return &joystick->base;
2502+}
2503+
2504diff -Naur old/src/evdev-joystick.h new/src/evdev-joystick.h
2505--- old/src/evdev-joystick.h	1970-01-01 08:00:00.000000000 +0800
2506+++ new/src/evdev-joystick.h	2024-01-01 00:00:00.000000000 +0800
2507@@ -0,0 +1,71 @@
2508+/*
2509+ * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2510+ * Licensed under the Apache License, Version 2.0 (the "License");
2511+ * you may not use this file except in compliance with the License.
2512+ * You may obtain a copy of the License at
2513+ *
2514+ *     http://www.apache.org/licenses/LICENSE-2.0
2515+ *
2516+ * Unless required by applicable law or agreed to in writing, software
2517+ * distributed under the License is distributed on an "AS IS" BASIS,
2518+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2519+ * See the License for the specific language governing permissions and
2520+ * limitations under the License.
2521+ */
2522+#ifndef LIBINPUT_EVDEV_JOYSTICK_H
2523+#define LIBINPUT_EVDEV_JOYSTICK_H
2524+
2525+#include "evdev.h"
2526+#include "libinput-private.h"
2527+
2528+struct joystick_dispatch {
2529+	struct evdev_dispatch base;
2530+	struct evdev_device* device;
2531+	uint32_t axis_value_mask;
2532+	struct joystick_axis_abs_infos axis_abs_infos;
2533+	struct {
2534+		struct libinput_device_config_send_events config;
2535+		enum libinput_config_send_events_mode current_mode;
2536+	} sendevents;
2537+};
2538+
2539+struct libinput_event_joystick_button {
2540+	struct libinput_event base;
2541+	uint32_t type;
2542+	uint64_t time;
2543+	uint32_t key;
2544+	uint32_t seat_key_count;
2545+	enum libinput_button_state state;
2546+	int value;
2547+};
2548+
2549+struct libinput_event_joystick_axis {
2550+	struct libinput_event base;
2551+    uint32_t type;
2552+	uint64_t time;
2553+	uint32_t axis_value_mask;
2554+	struct libinput_event_joystick_axis_abs_info abs_throttle;
2555+	struct libinput_event_joystick_axis_abs_info abs_hat0x;
2556+	struct libinput_event_joystick_axis_abs_info abs_hat0y;
2557+	struct libinput_event_joystick_axis_abs_info abs_x;
2558+	struct libinput_event_joystick_axis_abs_info abs_y;
2559+	struct libinput_event_joystick_axis_abs_info abs_z;
2560+	struct libinput_event_joystick_axis_abs_info abs_rx;
2561+	struct libinput_event_joystick_axis_abs_info abs_ry;
2562+	struct libinput_event_joystick_axis_abs_info abs_rz;
2563+	struct libinput_event_joystick_axis_abs_info abs_gas;
2564+	struct libinput_event_joystick_axis_abs_info abs_brake;
2565+};
2566+
2567+#ifdef _DEBUG
2568+void print_libinput_event_joystick_axis(struct libinput_event_joystick_axis* p);
2569+#endif // _DEBUG
2570+
2571+/**
2572+ * @brief 创建evdev_dispatch结构体
2573+ * @param device
2574+ * @return struct evdev_dispatch*
2575+*/
2576+struct evdev_dispatch* evdev_joystick_create(struct evdev_device* device);
2577+
2578+#endif
2579diff -Naur old/src/evdev-mt-touchpad-buttons.c new/src/evdev-mt-touchpad-buttons.c
2580--- old/src/evdev-mt-touchpad-buttons.c	2024-01-01 00:00:00.000000000 +0800
2581+++ new/src/evdev-mt-touchpad-buttons.c	2024-01-01 00:00:00.000000000 +0800
2582@@ -635,9 +635,9 @@
2583 	/* button height: 10mm or 15% or the touchpad height,
2584 	   whichever is smaller */
2585 	if (height * 0.15 > 10)
2586-		mm.y = height - 10;
2587+		mm.y = height - 18;
2588 	else
2589-		mm.y = height * 0.85;
2590+		mm.y = height * 0.78;
2591
2592 	mm.x = width * 0.5;
2593 	edges = evdev_device_mm_to_units(device, &mm);
2594@@ -1210,10 +1210,11 @@
2595 			return 0;
2596 	}
2597
2598-	evdev_pointer_notify_button(tp->device, time, button, state);
2599+	evdev_pointer_notify_button_touchpad(tp->device, time, button, state);
2600 	return 1;
2601 }
2602
2603+#define BTN_RIGHT_MENUE 0x118
2604 static int
2605 tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
2606 {
2607@@ -1288,7 +1289,7 @@
2608 		} else if (area & RIGHT) {
2609 			button = BTN_RIGHT;
2610 		} else if (area & LEFT) {
2611-			button = BTN_LEFT;
2612+			button = BTN_RIGHT_MENUE;
2613 		} else { /* main or no area (for clickfinger) is always BTN_LEFT */
2614 			button = BTN_LEFT;
2615 			want_left_handed = false;
2616diff -Naur old/src/evdev-mt-touchpad.c new/src/evdev-mt-touchpad.c
2617--- old/src/evdev-mt-touchpad.c	2024-01-01 00:00:00.000000000 +0800
2618+++ new/src/evdev-mt-touchpad.c	2024-01-01 00:00:00.000000000 +0800
2619@@ -330,6 +330,35 @@
2620 }
2621
2622 static inline void
2623+tp_tool_key_set(struct tp_dispatch *tp,
2624+		   unsigned int code,
2625+		   bool is_press)
2626+{
2627+	unsigned int shift = 0;
2628+
2629+	switch (code) {
2630+		case BTN_TOOL_PEN:
2631+		case BTN_TOOL_RUBBER:
2632+		case BTN_TOOL_BRUSH:
2633+		case BTN_TOOL_PENCIL:
2634+		case BTN_TOOL_AIRBRUSH:
2635+		case BTN_TOOL_FINGER:
2636+		case BTN_TOOL_MOUSE:
2637+		case BTN_TOOL_LENS:
2638+			shift = code - BTN_TOOL_PEN;
2639+			break;
2640+		default:
2641+			return;
2642+	}
2643+
2644+	if (is_press) {
2645+		tp->tool_touches |= 0x1 << shift;
2646+	} else {
2647+		tp->tool_touches &= ~(0x1 << shift);
2648+	}
2649+}
2650+
2651+static inline void
2652 tp_new_touch(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
2653 {
2654 	if (t->state == TOUCH_BEGIN ||
2655@@ -362,6 +391,7 @@
2656 	t->speed.last_speed = 0;
2657 	t->speed.exceeded_count = 0;
2658 	t->hysteresis.x_motion_history = 0;
2659+	t->seat_slot = -1;
2660 	tp->queued |= TOUCHPAD_EVENT_MOTION;
2661 }
2662
2663@@ -515,6 +545,81 @@
2664 	return absinfo->maximum - (value - absinfo->minimum);
2665 }
2666
2667+void tp_ext_post_event(struct tp_dispatch* dispatch, bool is_up, uint64_t time)
2668+{
2669+	struct tp_touch * t = tp_current_touch(dispatch);
2670+	int seat_slot = t->seat_slot;
2671+	if (is_up) {
2672+		if (seat_slot == -1) {
2673+			return;
2674+		}
2675+
2676+		dispatch->orginal.active_slot_count--;
2677+		if (dispatch->orginal.active_slot_count < 0) {
2678+			dispatch->orginal.active_slot_count = 0;
2679+		}
2680+
2681+		if (dispatch->orginal.active_slot_count == 0) {
2682+			dispatch->orginal.seat_slot_id = 0;
2683+		}
2684+
2685+		tp_tap_original_up(dispatch, t, time);
2686+		return;
2687+	}
2688+
2689+	if (seat_slot == -1) {
2690+		t->seat_slot = dispatch->orginal.seat_slot_id++;
2691+		dispatch->orginal.active_slot_count++;
2692+
2693+		tp_tap_original_down(dispatch, t, time);
2694+		return;
2695+	}
2696+
2697+	tp_tap_original_motion(dispatch, t, time);
2698+}
2699+
2700+void tp_ext_on_xy_update(struct tp_dispatch* dispatch)
2701+{
2702+	dispatch->orginal.xy_updated = true;
2703+}
2704+
2705+void tp_ext_on_mt_slot(struct tp_dispatch* dispatch, uint64_t time)
2706+{
2707+	if (dispatch->orginal.xy_updated) {
2708+		dispatch->orginal.xy_updated = false;
2709+		tp_ext_post_event(dispatch, false, time);
2710+		return;
2711+	};
2712+}
2713+
2714+void tp_ext_before_new_touch(struct tp_dispatch* dispatch, uint64_t time)
2715+{
2716+	if (dispatch->orginal.xy_updated) {
2717+		dispatch->orginal.xy_updated = false;
2718+		tp_ext_post_event(dispatch, false, time);
2719+		return;
2720+	};
2721+}
2722+
2723+void tp_ext_before_delete_touch(struct tp_dispatch* dispatch, uint64_t time)
2724+{
2725+	if (dispatch->orginal.xy_updated) {
2726+		dispatch->orginal.xy_updated = false;
2727+		tp_ext_post_event(dispatch, false, time);
2728+	};
2729+
2730+	tp_ext_post_event(dispatch, true, time);
2731+}
2732+
2733+void tp_ext_on_sync(struct tp_dispatch* dispatch, uint64_t time)
2734+{
2735+	if (dispatch->orginal.xy_updated) {
2736+		dispatch->orginal.xy_updated = false;
2737+		tp_ext_post_event(dispatch, false, time);
2738+		return;
2739+	};
2740+}
2741+
2742 static void
2743 tp_process_absolute(struct tp_dispatch *tp,
2744 		    const struct input_event *e,
2745@@ -524,6 +629,7 @@
2746
2747 	switch(e->code) {
2748 	case ABS_MT_POSITION_X:
2749+		tp_ext_on_xy_update(tp);
2750 		evdev_device_check_abs_axis_range(tp->device,
2751 						  e->code,
2752 						  e->value);
2753@@ -532,6 +638,7 @@
2754 		tp->queued |= TOUCHPAD_EVENT_MOTION;
2755 		break;
2756 	case ABS_MT_POSITION_Y:
2757+		tp_ext_on_xy_update(tp);
2758 		evdev_device_check_abs_axis_range(tp->device,
2759 						  e->code,
2760 						  e->value);
2761@@ -540,14 +647,17 @@
2762 		tp->queued |= TOUCHPAD_EVENT_MOTION;
2763 		break;
2764 	case ABS_MT_SLOT:
2765+		tp_ext_on_mt_slot(tp, time);
2766 		tp->slot = e->value;
2767 		break;
2768 	case ABS_MT_TRACKING_ID:
2769 		if (e->value != -1) {
2770+			tp_ext_before_new_touch(tp, time);
2771 			tp->nactive_slots += 1;
2772 			tp_new_touch(tp, t, time);
2773 		} else {
2774 			assert(tp->nactive_slots >= 1);
2775+			tp_ext_before_delete_touch(tp, time);
2776 			tp->nactive_slots -= 1;
2777 			tp_end_sequence(tp, t, time);
2778 		}
2779@@ -559,6 +669,7 @@
2780 		break;
2781 	case ABS_MT_TOOL_TYPE:
2782 		t->is_tool_palm = e->value == MT_TOOL_PALM;
2783+		t->tool_type = e->value;
2784 		t->dirty = true;
2785 		tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
2786 		break;
2787@@ -572,6 +683,26 @@
2788 		t->dirty = true;
2789 		tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
2790 		break;
2791+	case ABS_MT_WIDTH_MAJOR:
2792+		t->tool_rect.w = e->value;
2793+		t->dirty = true;
2794+		tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
2795+		break;
2796+	case ABS_MT_WIDTH_MINOR:
2797+		t->tool_rect.h = e->value;
2798+		t->dirty = true;
2799+		tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
2800+		break;
2801+	case ABS_MT_TOOL_X:
2802+		t->tool_rect.x = e->value;
2803+		t->dirty = true;
2804+		tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
2805+		break;
2806+	case ABS_MT_TOOL_Y:
2807+		t->tool_rect.y = e->value;
2808+		t->dirty = true;
2809+		tp->queued |= TOUCHPAD_EVENT_OTHERAXIS;
2810+		break;
2811 	}
2812 }
2813
2814@@ -783,6 +914,20 @@
2815 			tp_process_trackpoint_button(tp, e, time);
2816 			break;
2817 	}
2818+
2819+	switch (e->code) {
2820+		case BTN_TOOL_PEN:
2821+		case BTN_TOOL_RUBBER:
2822+		case BTN_TOOL_BRUSH:
2823+		case BTN_TOOL_PENCIL:
2824+		case BTN_TOOL_AIRBRUSH:
2825+		case BTN_TOOL_FINGER:
2826+		case BTN_TOOL_MOUSE:
2827+		case BTN_TOOL_LENS:
2828+			tp_tool_key_set(tp, e->code, !!e->value);
2829+		default:
2830+			break;
2831+	}
2832 }
2833
2834 static void
2835@@ -1958,6 +2103,7 @@
2836 		tp_process_msc(tp, e, time);
2837 		break;
2838 	case EV_SYN:
2839+		tp_ext_on_sync(tp, time);
2840 		tp_handle_state(tp, time);
2841 #if 0
2842 		tp_debug_touch_state(tp, device);
2843@@ -2860,6 +3006,8 @@
2844 	t->tp = tp;
2845 	t->has_ended = true;
2846 	t->index = index;
2847+	t->seat_slot = -1;
2848+	t->tool_type = -1;
2849 }
2850
2851 static inline void
2852@@ -3362,18 +3510,18 @@
2853 	if (width < 70.0)
2854 		return;
2855
2856-	/* palm edges are 8% of the width on each side */
2857-	mm.x = min(8, width * 0.08);
2858+	/* palm edges are 5mm of the width on each side */
2859+	mm.x = 5;
2860 	edges = evdev_device_mm_to_units(device, &mm);
2861 	tp->palm.left_edge = edges.x;
2862
2863-	mm.x = width - min(8, width * 0.08);
2864+	mm.x = width - 5;
2865 	edges = evdev_device_mm_to_units(device, &mm);
2866 	tp->palm.right_edge = edges.x;
2867
2868 	if (!tp->buttons.has_topbuttons && height > 55) {
2869-		/* top edge is 5% of the height */
2870-		mm.y = height * 0.05;
2871+		/* top edge is 5mm of the height */
2872+		mm.y = 5;
2873 		edges = evdev_device_mm_to_units(device, &mm);
2874 		tp->palm.upper_edge = edges.y;
2875 	}
2876@@ -3788,6 +3936,10 @@
2877 	if (tp->gesture.enabled)
2878 		device->seat_caps |= EVDEV_DEVICE_GESTURE;
2879
2880+	tp->orginal.seat_slot_id = 0;
2881+	tp->orginal.active_slot_count = 0;
2882+	tp->orginal.xy_updated = 0;
2883+
2884 	return true;
2885 }
2886
2887@@ -3971,6 +4123,14 @@
2888
2889 	tp = zalloc(sizeof *tp);
2890
2891+	const struct input_absinfo* absInfo = device->is_mt ? libevdev_get_abs_info(device->evdev, ABS_MT_PRESSURE)
2892+		: libevdev_get_abs_info(device->evdev, ABS_PRESSURE);
2893+	if (absInfo == NULL) {
2894+		device->pressureMax = 0.0;
2895+	} else {
2896+		device->pressureMax = absInfo->maximum;
2897+	}
2898+
2899 	if (!tp_init(tp, device)) {
2900 		tp_interface_destroy(&tp->base);
2901 		return NULL;
2902@@ -3988,3 +4148,27 @@
2903
2904 	return &tp->base;
2905 }
2906+
2907+bool
2908+evdev_device_touchpad_btn_tool_type_down(struct evdev_device *device, int32_t btnToolType)
2909+{
2910+	struct tp_dispatch *tp = tp_dispatch(device->dispatch);
2911+
2912+	unsigned int shift = 0;
2913+	switch (btnToolType) {
2914+	case BTN_TOOL_PEN:
2915+	case BTN_TOOL_RUBBER:
2916+	case BTN_TOOL_BRUSH:
2917+	case BTN_TOOL_PENCIL:
2918+	case BTN_TOOL_AIRBRUSH:
2919+	case BTN_TOOL_FINGER:
2920+	case BTN_TOOL_MOUSE:
2921+	case BTN_TOOL_LENS:
2922+		shift = btnToolType - BTN_TOOL_PEN;
2923+		break;
2924+	default:
2925+		return false;
2926+	}
2927+
2928+	return (tp->tool_touches >> shift) & 0x1;
2929+}
2930diff -Naur old/src/evdev-mt-touchpad-gestures.c new/src/evdev-mt-touchpad-gestures.c
2931--- old/src/evdev-mt-touchpad-gestures.c	2024-01-01 00:00:00.000000000 +0800
2932+++ new/src/evdev-mt-touchpad-gestures.c	2024-01-01 00:00:00.000000000 +0800
2933@@ -124,6 +124,37 @@
2934 }
2935
2936 static void
2937+tp_get_raw_touches(struct tp_dispatch *tp, struct sloted_coords_info *raw_touches)
2938+{
2939+	struct tp_touch *t;
2940+	unsigned int i;
2941+	raw_touches->active_count = 0;
2942+
2943+	if (tp->num_slots > MAX_SOLTED_COORDS_NUM) {
2944+		evdev_log_bug_libinput(tp->device,
2945+				       "in %s, num_slots: %d, more than %d\n",
2946+				       __func__, tp->num_slots, MAX_SOLTED_COORDS_NUM);
2947+	}
2948+	const unsigned int num_slots = (tp->num_slots > MAX_SOLTED_COORDS_NUM) ? MAX_SOLTED_COORDS_NUM : tp->num_slots;
2949+
2950+	for (i = 0; i < num_slots; i++) {
2951+		t = &tp->touches[i];
2952+
2953+		if (!tp_touch_active_for_gesture(tp, t))
2954+			continue;
2955+
2956+		if (t->dirty) {
2957+			struct device_coords d;
2958+			d = tp_get_delta(t);
2959+			raw_touches->coords[i].x = d.x;
2960+			raw_touches->coords[i].y = d.y;
2961+		}
2962+		raw_touches->coords[i].is_active = true;
2963+		raw_touches->active_count++;
2964+	}
2965+}
2966+
2967+static void
2968 tp_gesture_init_scroll(struct tp_dispatch *tp)
2969 {
2970 	struct phys_coords zero = {0.0, 0.0};
2971@@ -169,6 +200,9 @@
2972 		break;
2973 	case GESTURE_STATE_SCROLL:
2974 		tp_gesture_init_scroll(tp);
2975+		gesture_notify_axis_finger(&tp->device->base, time,
2976+					LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN,
2977+					0, &zero);
2978 		break;
2979 	case GESTURE_STATE_PINCH:
2980 		gesture_notify_pinch(&tp->device->base, time,
2981@@ -180,7 +214,7 @@
2982 		gesture_notify_swipe(&tp->device->base, time,
2983 				     LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
2984 				     tp->gesture.finger_count,
2985-				     &zero, &zero);
2986+				     &zero, &zero, NULL);
2987 		break;
2988 	case GESTURE_STATE_POINTER_MOTION:
2989 		break;
2990@@ -233,7 +267,7 @@
2991 		struct device_float_coords unaccel;
2992
2993 		unaccel = tp_scale_to_xaxis(tp, raw);
2994-		pointer_notify_motion(&tp->device->base,
2995+		touchpad_pointer_notify_motion(&tp->device->base,
2996 				      time,
2997 				      &delta,
2998 				      &unaccel);
2999@@ -1190,14 +1224,150 @@
3000 			  &delta);
3001 }
3002
3003+static double
3004+calculate_cosine_similarity(struct tp_dispatch *tp, struct device_coords *delta1, struct device_coords *delta2)
3005+{
3006+
3007+	double dx1 = delta1->x;
3008+	double dy1 = delta1->y;
3009+	double dx2 = delta2->x;
3010+	double dy2 = delta2->y;
3011+
3012+	double dist1 = sqrt(dx1 * dx1 + dy1 * dy1);
3013+	double dist2 = sqrt(dx2 * dx2 + dy2 * dy2);
3014+
3015+	if (dist1 < 1 && dist2 < 1) {
3016+		return 0.0;
3017+	}
3018+	double ret = (dx1 * dx2 + dy1 * dy2) / (dist1 * dist2);
3019+
3020+	return ret;
3021+}
3022+
3023+static double
3024+calculate_finger_speed(struct tp_dispatch *tp, struct device_coords *curr_coord, struct device_coords *pre_coord)
3025+{
3026+	int delta_x = curr_coord->x - pre_coord->x;
3027+	int delta_y = curr_coord->y - pre_coord->y;
3028+
3029+	return sqrt(delta_x * delta_x + delta_y * delta_y);
3030+}
3031+
3032+struct gesture_device_coords {
3033+	struct device_coords coords[5];
3034+	int coords_len;
3035+};
3036+
3037+#define FINGER_COUNT_MAX 5
3038+static struct gesture_device_coords *
3039+get_gesture_device_coords(void)
3040+{
3041+	static struct gesture_device_coords gesture_coords = {
3042+		{{0, 0},
3043+		{0, 0},
3044+		{0, 0},
3045+		{0, 0},
3046+		{0, 0},},
3047+		FINGER_COUNT_MAX
3048+	};
3049+
3050+	return &gesture_coords;
3051+}
3052+
3053+static void
3054+updata_gesture_device_coords(struct device_coords *coords, int coords_len)
3055+{
3056+	struct gesture_device_coords * gesture_coords = get_gesture_device_coords();
3057+	memcpy(gesture_coords->coords, coords, coords_len * sizeof(struct device_coords));
3058+	gesture_coords->coords_len = coords_len;
3059+}
3060+
3061+static void
3062+reset_gesture_device_coords(void)
3063+{
3064+	struct gesture_device_coords * gesture_coords = get_gesture_device_coords();
3065+	memset(gesture_coords->coords, 0, FINGER_COUNT_MAX * sizeof(struct device_coords));
3066+	gesture_coords->coords_len = FINGER_COUNT_MAX;
3067+}
3068+
3069+#define FOUR_FINGER_SIMILAR_CNT 6
3070+#define THREE_FINGER_SIMILAR_CNT 3
3071+static bool
3072+calculate_swipe_cosine_similarity(struct tp_dispatch *tp, struct device_coords *coords, int coordsLen)
3073+{
3074+	// 3 or 4 finger
3075+	double similaritys[FOUR_FINGER_SIMILAR_CNT] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
3076+	if (coordsLen == 3 || coordsLen == 4) {
3077+		uint idx = 0;
3078+		for (int i = 0; i < coordsLen; i++) {
3079+			for (int j = i + 1; j < coordsLen; j++) {
3080+				similaritys[idx] = calculate_cosine_similarity(tp, &coords[i], &coords[j]);
3081+				idx++;
3082+			}
3083+		}
3084+	} else {
3085+		return 0.0;
3086+	}
3087+
3088+	int similarity_count = 0;
3089+	double sum = 0.0;
3090+	double ave = 0.0;
3091+	double variance = 0.0;
3092+
3093+	similarity_count = (coordsLen == 4) ? FOUR_FINGER_SIMILAR_CNT : THREE_FINGER_SIMILAR_CNT;
3094+	for (int i = 0; i < similarity_count; i++) {
3095+		sum += similaritys[i];
3096+	}
3097+	ave = sum / similarity_count;
3098+
3099+	// Calculate  variance
3100+	for (int i = 0; i < similarity_count; i++) {
3101+		variance += pow(similaritys[i] - ave, 2) / similarity_count;
3102+	}
3103+
3104+	// variance <= 0.001 are the same direction
3105+	return variance < 0.001 ? true : false;
3106+}
3107+
3108+static void
3109+tp_gesture_handle_state_swipe_private(struct tp_dispatch *tp, uint64_t time)
3110+{
3111+	struct device_float_coords raw;
3112+	struct normalized_coords delta, unaccel;
3113+
3114+	raw = tp_get_average_touches_delta(tp);
3115+	delta = tp_filter_motion(tp, &raw, time);
3116+
3117+	if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) {
3118+		unaccel = tp_normalize_delta(tp, raw);
3119+		tp_gesture_start(tp, time);
3120+
3121+		struct device_coords coords[5];
3122+		for (uint32_t i = 0; i < tp->nfingers_down; i++) {
3123+			coords[i] = tp->touches[i].point;
3124+		}
3125+
3126+		if (calculate_swipe_cosine_similarity(tp, coords, tp->nfingers_down) == false) {
3127+			evdev_log_error(tp->device, "libinput gesture is unknown.");
3128+		}
3129+
3130+		gesture_notify_swipe_private(&tp->device->base, time,
3131+				     LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
3132+				     tp->gesture.finger_count,
3133+				     &delta, &unaccel, coords, tp->nfingers_down);
3134+	}
3135+}
3136+
3137 static void
3138 tp_gesture_handle_state_swipe(struct tp_dispatch *tp, uint64_t time)
3139 {
3140 	struct device_float_coords raw;
3141+	struct sloted_coords_info raw_touches = {};
3142 	struct normalized_coords delta, unaccel;
3143
3144 	raw = tp_get_average_touches_delta(tp);
3145 	delta = tp_filter_motion(tp, &raw, time);
3146+	tp_get_raw_touches(tp, &raw_touches);
3147
3148 	if (!normalized_is_zero(delta) || !device_float_is_zero(raw)) {
3149 		unaccel = tp_filter_motion_unaccelerated(tp, &raw, time);
3150@@ -1205,7 +1375,7 @@
3151 		gesture_notify_swipe(&tp->device->base, time,
3152 				     LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
3153 				     tp->gesture.finger_count,
3154-				     &delta, &unaccel);
3155+				     &delta, &unaccel, &raw_touches);
3156 	}
3157 }
3158
3159@@ -1269,7 +1439,7 @@
3160 		tp_gesture_handle_state_scroll(tp, time);
3161
3162 	if (tp->gesture.state == GESTURE_STATE_SWIPE)
3163-		tp_gesture_handle_state_swipe(tp, time);
3164+		tp_gesture_handle_state_swipe_private(tp, time);
3165
3166 	if (tp->gesture.state == GESTURE_STATE_PINCH)
3167 		tp_gesture_handle_state_pinch(tp, time);
3168diff -Naur old/src/evdev-mt-touchpad.h new/src/evdev-mt-touchpad.h
3169--- old/src/evdev-mt-touchpad.h	2024-01-01 00:00:00.000000000 +0800
3170+++ new/src/evdev-mt-touchpad.h	2024-01-01 00:00:00.000000000 +0800
3171@@ -132,6 +132,7 @@
3172 	TAP_STATE_2FGTAP_DRAGGING_2,
3173 	TAP_STATE_3FGTAP_DRAGGING_2,
3174 	TAP_STATE_DEAD, /**< finger count exceeded */
3175+	TAP_STATE_HOLDING,
3176 };
3177
3178 enum tp_tap_touch_state {
3179@@ -192,10 +193,14 @@
3180 	int pressure;
3181 	bool is_tool_palm; /* MT_TOOL_PALM */
3182 	int major, minor;
3183+    struct device_coord_rect tool_rect;
3184
3185 	bool was_down; /* if distance == 0, false for pure hovering
3186 			  touches */
3187
3188+	int seat_slot;
3189+	int tool_type;
3190+
3191 	struct {
3192 		/* A quirk mostly used on Synaptics touchpads. In a
3193 		   transition to/from fake touches > num_slots, the current
3194@@ -310,6 +315,17 @@
3195 	 */
3196 	unsigned int fake_touches;
3197
3198+	/* bit 0: BTN_TOOL_PEN
3199+	 * bit 1: BTN_TOOL_RUBBER
3200+	 * bit 2: BTN_TOOL_BRUSH
3201+	 * bit 3: BTN_TOOL_PENCIL
3202+	 * bit 4: BTN_TOOL_AIRBRUSH
3203+	 * bit 5: BTN_TOOL_FINGER
3204+	 * bit 6: BTN_TOOL_MOUSE
3205+	 * bit 7: BTN_TOOL_LENS
3206+	 */
3207+	unsigned int tool_touches;
3208+
3209 	struct {
3210 		bool detection_disabled;
3211 		struct ratelimit warning;
3212@@ -535,6 +551,12 @@
3213 		struct evdev_device *tablet_device;
3214 		bool tablet_left_handed_state;
3215 	} left_handed;
3216+
3217+	struct {
3218+		int seat_slot_id;
3219+		int active_slot_count;
3220+		int xy_updated;
3221+	} orginal;
3222 };
3223
3224 static inline struct tp_dispatch*
3225@@ -767,4 +789,19 @@
3226 struct tp_touch*
3227 tp_thumb_get_touch(struct tp_dispatch *tp);
3228
3229+void
3230+tp_tap_original_down(struct tp_dispatch *tp,
3231+		    struct tp_touch *t,
3232+		    uint64_t time);
3233+
3234+void
3235+tp_tap_original_up(struct tp_dispatch *tp,
3236+		    struct tp_touch *t,
3237+		    uint64_t time);
3238+
3239+void
3240+tp_tap_original_motion(struct tp_dispatch *tp,
3241+		    struct tp_touch *t,
3242+		    uint64_t time);
3243+
3244 #endif
3245diff -Naur old/src/evdev-mt-touchpad-tap.c new/src/evdev-mt-touchpad-tap.c
3246--- old/src/evdev-mt-touchpad-tap.c	2024-01-01 00:00:00.000000000 +0800
3247+++ new/src/evdev-mt-touchpad-tap.c	2024-01-01 00:00:00.000000000 +0800
3248@@ -88,6 +88,7 @@
3249 	CASE_RETURN_STRING(TAP_STATE_2FGTAP_DRAGGING_2);
3250 	CASE_RETURN_STRING(TAP_STATE_3FGTAP_DRAGGING_2);
3251 	CASE_RETURN_STRING(TAP_STATE_DEAD);
3252+	CASE_RETURN_STRING(TAP_STATE_HOLDING);
3253 	}
3254 	return NULL;
3255 }
3256@@ -125,6 +126,10 @@
3257 	      int nfingers,
3258 	      enum libinput_button_state state)
3259 {
3260+	if (tp->tap.state == TAP_STATE_IDLE) {
3261+		return;
3262+	}
3263+
3264 	int32_t button;
3265 	int32_t button_map[2][3] = {
3266 		{ BTN_LEFT, BTN_RIGHT, BTN_MIDDLE },
3267@@ -138,12 +143,16 @@
3268
3269 	button = button_map[tp->tap.map][nfingers - 1];
3270
3271+	if (tp->device->key_count[button] == 0 &&
3272+		state == LIBINPUT_BUTTON_STATE_RELEASED)
3273+		return;
3274+
3275 	if (state == LIBINPUT_BUTTON_STATE_PRESSED)
3276 		tp->tap.buttons_pressed |= bit(nfingers);
3277 	else
3278 		tp->tap.buttons_pressed &= ~bit(nfingers);
3279
3280-	evdev_pointer_notify_button(tp->device,
3281+	evdev_pointer_notify_tap(tp->device,
3282 				    time,
3283 				    button,
3284 				    state);
3285@@ -264,6 +273,10 @@
3286 		tp->tap.nfingers_down--;
3287 		t->tap.state = TAP_TOUCH_STATE_DEAD;
3288 		tp_tap_clear_timer(tp);
3289+		tp_tap_notify(tp,
3290+			      tp->tap.saved_press_time,
3291+			      1,
3292+			      LIBINPUT_BUTTON_STATE_PRESSED);
3293 		break;
3294 	case TAP_EVENT_PALM:
3295 		tp->tap.state = TAP_STATE_IDLE;
3296@@ -290,8 +303,48 @@
3297 		tp->tap.state = TAP_STATE_IDLE;
3298 		break;
3299 	case TAP_EVENT_MOTION:
3300+		tp->tap.state = TAP_STATE_HOLDING;
3301+		break;
3302+	case TAP_EVENT_TIMEOUT:
3303+		break;
3304+	case TAP_EVENT_BUTTON:
3305+		tp->tap.state = TAP_STATE_DEAD;
3306+		break;
3307+	case TAP_EVENT_THUMB:
3308+		tp->tap.state = TAP_STATE_IDLE;
3309+		t->tap.is_thumb = true;
3310+		tp->tap.nfingers_down--;
3311+		t->tap.state = TAP_TOUCH_STATE_DEAD;
3312+		break;
3313+	case TAP_EVENT_PALM:
3314+		tp->tap.state = TAP_STATE_IDLE;
3315+		break;
3316+	case TAP_EVENT_PALM_UP:
3317+		break;
3318+	}
3319+	if ((tp->tap.state != TAP_STATE_HOLDING) && (tp->tap.state != TAP_STATE_HOLD)) {
3320+		tp_tap_notify(tp,
3321+			      tp->tap.saved_press_time,
3322+			      1,
3323+			      LIBINPUT_BUTTON_STATE_RELEASED);
3324+	}
3325+}
3326+
3327+static void
3328+tp_tap_holding_handle_event(struct tp_dispatch *tp,
3329+			    struct tp_touch *t,
3330+			    enum tap_event event, uint64_t time)
3331+{
3332+
3333+	switch (event) {
3334+	case TAP_EVENT_TOUCH:
3335 		tp_tap_move_to_dead(tp, t);
3336 		break;
3337+	case TAP_EVENT_RELEASE:
3338+		tp->tap.state = TAP_STATE_IDLE;
3339+		break;
3340+	case TAP_EVENT_MOTION:
3341+		break;
3342 	case TAP_EVENT_TIMEOUT:
3343 		break;
3344 	case TAP_EVENT_BUTTON:
3345@@ -309,6 +362,12 @@
3346 	case TAP_EVENT_PALM_UP:
3347 		break;
3348 	}
3349+	if (tp->tap.state != TAP_STATE_HOLDING) {
3350+		tp_tap_notify(tp,
3351+			      tp->tap.saved_press_time,
3352+			      1,
3353+			      LIBINPUT_BUTTON_STATE_RELEASED);
3354+    }
3355 }
3356
3357 static void
3358@@ -1143,6 +1202,9 @@
3359 	case TAP_STATE_DEAD:
3360 		tp_tap_dead_handle_event(tp, t, event, time);
3361 		break;
3362+	case TAP_STATE_HOLDING:
3363+		tp_tap_holding_handle_event(tp, t, event, time);
3364+		break;
3365 	}
3366
3367 	if (tp->tap.state == TAP_STATE_IDLE || tp->tap.state == TAP_STATE_DEAD)
3368@@ -1419,23 +1481,7 @@
3369 static enum libinput_config_tap_state
3370 tp_tap_default(struct evdev_device *evdev)
3371 {
3372-	/**
3373-	 * If we don't have a left button we must have tapping enabled by
3374-	 * default.
3375-	 */
3376-	if (!libevdev_has_event_code(evdev->evdev, EV_KEY, BTN_LEFT))
3377-		return LIBINPUT_CONFIG_TAP_ENABLED;
3378-
3379-	/**
3380-	 * Tapping is disabled by default for two reasons:
3381-	 * * if you don't know that tapping is a thing (or enabled by
3382-	 *   default), you get spurious mouse events that make the desktop
3383-	 *   feel buggy.
3384-	 * * if you do know what tapping is and you want it, you
3385-	 *   usually know where to enable it, or at least you can search for
3386-	 *   it.
3387-	 */
3388-	return LIBINPUT_CONFIG_TAP_DISABLED;
3389+	return LIBINPUT_CONFIG_TAP_ENABLED;
3390 }
3391
3392 static enum libinput_config_tap_state
3393@@ -1499,7 +1545,7 @@
3394 static inline enum libinput_config_drag_state
3395 tp_drag_default(struct evdev_device *device)
3396 {
3397-	return LIBINPUT_CONFIG_DRAG_ENABLED;
3398+	return LIBINPUT_CONFIG_DRAG_DISABLED;
3399 }
3400
3401 static enum libinput_config_drag_state
3402@@ -1661,3 +1707,63 @@
3403 		return false;
3404 	}
3405 }
3406+
3407+void
3408+tp_tap_original_down(struct tp_dispatch *tp,
3409+		    struct tp_touch *t,
3410+		    uint64_t time)
3411+{
3412+	struct libinput_device *base = &tp->device->base;
3413+	struct evdev_device *device = tp->device;
3414+	int slot_idx = tp->slot;
3415+	int seat_slot = t->seat_slot;
3416+	int32_t pressure = t->pressure;
3417+	int tool_type = t->tool_type;
3418+	struct device_coords point;
3419+	struct device_coord_rect rect;
3420+	point = t->point;
3421+	struct touch_axis axis;
3422+	axis.major = t->major;
3423+	axis.minor = t->minor;
3424+	rect = t->tool_rect;
3425+	evdev_transform_absolute_rect(device, &rect);
3426+	touchpad_notify_touch_down(base, time, slot_idx, seat_slot, pressure, tool_type, axis, &point, &rect);
3427+}
3428+
3429+void
3430+tp_tap_original_up(struct tp_dispatch *tp,
3431+		    struct tp_touch *t,
3432+		    uint64_t time)
3433+{
3434+	struct libinput_device *base = &tp->device->base;
3435+	int slot_idx = tp->slot;
3436+	int seat_slot = t->seat_slot;
3437+	t->seat_slot = -1;
3438+	int tool_type = t->tool_type;
3439+	struct touch_axis axis;
3440+	axis.major = t->major;
3441+	axis.minor = t->minor;
3442+	touchpad_notify_touch_up(base, time, slot_idx, seat_slot, tool_type, axis);
3443+}
3444+
3445+void
3446+tp_tap_original_motion(struct tp_dispatch *tp,
3447+		    struct tp_touch *t,
3448+		    uint64_t time)
3449+{
3450+	struct libinput_device *base = &tp->device->base;
3451+	struct evdev_device *device = tp->device;
3452+	int seat_slot = t->seat_slot;
3453+	int slot_idx = tp->slot;
3454+	int32_t pressure = t->pressure;
3455+	int tool_type = t->tool_type;
3456+	struct device_coords point;
3457+    struct device_coord_rect rect;
3458+	point = t->point;
3459+	struct touch_axis axis;
3460+	axis.major = t->major;
3461+	axis.minor = t->minor;
3462+	rect = t->tool_rect;
3463+	evdev_transform_absolute_rect(device, &rect);
3464+	touchpad_notify_touch_motion(base, time, slot_idx, seat_slot, pressure, tool_type, axis, &point, &rect);
3465+}
3466\ No newline at end of file
3467diff -Naur old/src/evdev-privacy-switch.c new/src/evdev-privacy-switch.c
3468--- old/src/evdev-privacy-switch.c	1970-01-01 08:00:00.000000000 +0800
3469+++ new/src/evdev-privacy-switch.c	2024-01-01 00:00:00.000000000 +0800
3470@@ -0,0 +1,300 @@
3471+/*
3472+ * Copyright (c) 2024 Huawei Device Co., Ltd.
3473+ * Licensed under the Apache License, Version 2.0 (the "License");
3474+ * you may not use this file except in compliance with the License.
3475+ * You may obtain a copy of the License at
3476+ *
3477+ *     http://www.apache.org/licenses/LICENSE-2.0
3478+ *
3479+ * Unless required by applicable law or agreed to in writing, software
3480+ * distributed under the License is distributed on an "AS IS" BASIS,
3481+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3482+ * See the License for the specific language governing permissions and
3483+ * limitations under the License.
3484+ */
3485+
3486+#include <stdbool.h>
3487+#include <string.h>
3488+
3489+#include "config.h"
3490+#include "libinput-version.h"
3491+#include "evdev-privacy-switch.h"
3492+#include "libinput.h"
3493+#include "libinput-util.h"
3494+
3495+struct privacy_switch_dispatch {
3496+	struct evdev_dispatch base;
3497+	struct evdev_device* device;
3498+	uint64_t time;
3499+	uint32_t mask;
3500+	struct privacy_switch ev_switch;
3501+	struct {
3502+		struct libinput_device_config_send_events config;
3503+		enum libinput_config_send_events_mode current_mode;
3504+	} sendevents;
3505+};
3506+
3507+static inline struct
3508+privacy_switch_dispatch* get_privacy_switch_dispatch(struct evdev_dispatch* dispatch)
3509+{
3510+    evdev_verify_dispatch_type(dispatch, DISPATCH_PRIVACY_SWITCH);
3511+
3512+    struct privacy_switch_dispatch* pSwitchDispatch = NULL;
3513+    pSwitchDispatch = container_of(dispatch, struct privacy_switch_dispatch, base);
3514+
3515+    return pSwitchDispatch;
3516+}
3517+
3518+static void
3519+privacy_switch_post_event(struct privacy_switch_dispatch* pSwitchDispatch,
3520+    struct evdev_device* device, struct input_event* event, uint64_t time)
3521+{
3522+    if (pSwitchDispatch == NULL || device == NULL || event == NULL) {
3523+        return;
3524+    }
3525+    pSwitchDispatch->mask = 1;
3526+    pSwitchDispatch->ev_switch.time = time;
3527+    pSwitchDispatch->ev_switch.sw = LIBINPUT_SWITCH_PRIVACY;
3528+
3529+
3530+    if (event->value == 1) {
3531+        pSwitchDispatch->ev_switch.state = LIBINPUT_SWITCH_STATE_ON;
3532+    } else {
3533+        pSwitchDispatch->ev_switch.state = LIBINPUT_SWITCH_STATE_OFF;
3534+    }
3535+}
3536+
3537+static inline void privacy_switch_reset_mask(struct privacy_switch_dispatch* pSwitchDispatch)
3538+{
3539+	pSwitchDispatch->mask = 0;
3540+}
3541+
3542+static void
3543+privacy_switch_flush(struct privacy_switch_dispatch* pSwitchDispatch, struct evdev_device* device, uint64_t time)
3544+{
3545+    if (pSwitchDispatch == NULL || device == NULL) {
3546+        return;
3547+    }
3548+
3549+    if (pSwitchDispatch->mask == 1) {
3550+        privacy_switch_notify_event(&device->base, time, &pSwitchDispatch->ev_switch);
3551+        privacy_switch_reset_mask(pSwitchDispatch);
3552+    }
3553+}
3554+
3555+static void
3556+privacy_switch_process(struct evdev_dispatch* dispatch, struct evdev_device* device,
3557+    struct input_event* event, uint64_t time)
3558+{
3559+    if (dispatch == NULL || device == NULL || event == NULL) {
3560+        return;
3561+    }
3562+
3563+    struct privacy_switch_dispatch* pSwitchDispatch = get_privacy_switch_dispatch(dispatch);
3564+    if (pSwitchDispatch == NULL) {
3565+        return;
3566+    }
3567+
3568+    switch (event->type) {
3569+    case EV_SW: {
3570+        privacy_switch_post_event(pSwitchDispatch, device, event, time);
3571+    }
3572+    break;
3573+    case EV_SYN: {
3574+        privacy_switch_flush(pSwitchDispatch, device, time);
3575+    }
3576+    break;
3577+    default:
3578+        libinput_log_printf("unsupported privacy_switch event type: %d, devname: %s.\n", event->type, device->devname);
3579+    break;
3580+    }
3581+}
3582+
3583+static void
3584+privacy_switch_destroy(struct evdev_dispatch* dispatch)
3585+{
3586+    if (dispatch == NULL) {
3587+        return;
3588+    }
3589+    struct privacy_switch_dispatch* pSwitchDispatch = get_privacy_switch_dispatch(dispatch);
3590+    if (pSwitchDispatch == NULL) {
3591+        return;
3592+    }
3593+
3594+    free(pSwitchDispatch);
3595+}
3596+
3597+static void
3598+privacy_switch_device_added(struct evdev_device* device,
3599+    struct evdev_device* added_device)
3600+{
3601+    if (device == NULL || added_device == NULL || device->dispatch == NULL) {
3602+        return;
3603+    }
3604+    struct privacy_switch_dispatch* privacy_switch_dispatch = get_privacy_switch_dispatch(device->dispatch);
3605+    if (privacy_switch_dispatch == NULL) {
3606+        return;
3607+    }
3608+    if (libinput_device_get_device_group(&device->base) !=
3609+        libinput_device_get_device_group(&added_device->base)) {
3610+        return;
3611+    }
3612+    bool is_privacy_switch = false;
3613+    is_privacy_switch = evdev_device_has_capability(added_device,
3614+        LIBINPUT_DEVICE_CAP_SWITCH);
3615+
3616+    if (is_privacy_switch) {
3617+        evdev_log_debug(device,
3618+            "privacy_switch: activated for %s<->%s\n",
3619+            device->devname,
3620+            added_device->devname);
3621+        privacy_switch_dispatch->device = added_device;
3622+    }
3623+}
3624+
3625+static void
3626+privacy_switch_device_removed(struct evdev_device* device, struct evdev_device* removed_device)
3627+{
3628+    if (device == NULL || removed_device == NULL) {
3629+        return;
3630+    }
3631+    struct privacy_switch_dispatch* pSwitchDispatch = get_privacy_switch_dispatch(device->dispatch);
3632+    if (pSwitchDispatch == NULL) {
3633+        return;
3634+    }
3635+
3636+    if (pSwitchDispatch->device == removed_device) {
3637+        pSwitchDispatch->device = NULL;
3638+    }
3639+}
3640+
3641+static void privacy_switch_suspend(struct evdev_dispatch* dispatch, struct evdev_device* device)
3642+{
3643+    if (dispatch == NULL || device == NULL) {
3644+        return;
3645+    }
3646+    struct privacy_switch_dispatch* pSwitchDispatch = get_privacy_switch_dispatch(dispatch);
3647+    if (pSwitchDispatch == NULL) {
3648+        return;
3649+    }
3650+    privacy_switch_flush(pSwitchDispatch, device, 0);
3651+}
3652+
3653+static struct evdev_dispatch_interface privacy_switch_interface = {
3654+    .process = privacy_switch_process,
3655+    .suspend = privacy_switch_suspend,
3656+    .remove = NULL,
3657+    .destroy = privacy_switch_destroy,
3658+    .device_added = privacy_switch_device_added,
3659+    .device_removed = privacy_switch_device_removed,
3660+    .device_suspended = NULL,
3661+    .device_resumed = NULL,
3662+    .post_added = NULL,
3663+    .touch_arbitration_toggle = NULL,
3664+    .touch_arbitration_update_rect = NULL,
3665+    .get_switch_state = NULL,
3666+};
3667+
3668+static enum libinput_config_status
3669+privacy_switch_sendevents_set_mode(struct libinput_device* device,
3670+    enum libinput_config_send_events_mode mode)
3671+{
3672+    if (device == NULL)     {
3673+        return LIBINPUT_CONFIG_STATUS_INVALID;
3674+    }
3675+
3676+    struct evdev_device* ev_device = evdev_device(device);
3677+    struct privacy_switch_dispatch* pSwitchDispatch = (struct privacy_switch_dispatch*)ev_device->dispatch;
3678+
3679+    if (ev_device == NULL || pSwitchDispatch == NULL) {
3680+        return LIBINPUT_CONFIG_STATUS_INVALID;
3681+    }
3682+
3683+    if (mode == pSwitchDispatch->sendevents.current_mode) {
3684+        return LIBINPUT_CONFIG_STATUS_SUCCESS;
3685+    }
3686+
3687+    switch (mode) {
3688+    case LIBINPUT_CONFIG_SEND_EVENTS_ENABLED:
3689+        break;
3690+    case LIBINPUT_CONFIG_SEND_EVENTS_DISABLED:
3691+        privacy_switch_suspend(ev_device->dispatch, ev_device);
3692+        break;
3693+    default:
3694+        return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
3695+    }
3696+
3697+    pSwitchDispatch->sendevents.current_mode = mode;
3698+
3699+    return LIBINPUT_CONFIG_STATUS_SUCCESS;
3700+}
3701+
3702+static uint32_t
3703+privacy_switch_sendevents_get_modes(struct libinput_device* device)
3704+{
3705+    return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
3706+}
3707+
3708+static enum libinput_config_send_events_mode
3709+privacy_switch_sendevents_get_mode(struct libinput_device* device)
3710+{
3711+    if (device == NULL) {
3712+        return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
3713+    }
3714+
3715+    struct evdev_device* ev_device = evdev_device(device);
3716+    struct privacy_switch_dispatch* pDispatch = (struct privacy_switch_dispatch*)ev_device->dispatch;
3717+
3718+    if (ev_device == NULL || pDispatch == NULL) {
3719+        return LIBINPUT_CONFIG_SEND_EVENTS_DISABLED;
3720+    }
3721+
3722+    return pDispatch->sendevents.current_mode;
3723+}
3724+
3725+static enum libinput_config_send_events_mode
3726+privacy_switch_sendevents_get_default_mode(struct libinput_device* device)
3727+{
3728+    return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
3729+}
3730+
3731+static bool
3732+privacy_switch_init(struct privacy_switch_dispatch* pSwitch, struct evdev_device* device)
3733+{
3734+    if (pSwitch == NULL || device == NULL) {
3735+        return false;
3736+    }
3737+
3738+    pSwitch->base.dispatch_type = DISPATCH_PRIVACY_SWITCH;
3739+    pSwitch->base.interface = &privacy_switch_interface;
3740+    pSwitch->device = device;
3741+
3742+    return true;
3743+}
3744+
3745+struct evdev_dispatch*
3746+evdev_privacy_switch_create(struct evdev_device* device)
3747+{
3748+    if (device == NULL) {
3749+        return NULL;
3750+    }
3751+
3752+    struct privacy_switch_dispatch* privacySwitch = NULL;
3753+    privacySwitch = zalloc(sizeof * privacySwitch);
3754+
3755+    if (!privacy_switch_init(privacySwitch, device)) {
3756+        privacy_switch_destroy(&privacySwitch->base);
3757+        privacySwitch = NULL;
3758+        return NULL;
3759+    }
3760+
3761+    device->base.config.sendevents = &privacySwitch->sendevents.config;
3762+    privacySwitch->sendevents.current_mode = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
3763+    privacySwitch->sendevents.config.get_modes = privacy_switch_sendevents_get_modes;
3764+    privacySwitch->sendevents.config.set_mode = privacy_switch_sendevents_set_mode;
3765+    privacySwitch->sendevents.config.get_mode = privacy_switch_sendevents_get_mode;
3766+    privacySwitch->sendevents.config.get_default_mode = privacy_switch_sendevents_get_default_mode;
3767+
3768+    return &privacySwitch->base;
3769+}
3770+
3771diff -Naur old/src/evdev-privacy-switch.h new/src/evdev-privacy-switch.h
3772--- old/src/evdev-privacy-switch.h	1970-01-01 08:00:00.000000000 +0800
3773+++ new/src/evdev-privacy-switch.h	2024-01-01 00:00:00.000000000 +0800
3774@@ -0,0 +1,29 @@
3775+/*
3776+ * Copyright (c) 2024 Huawei Device Co., Ltd.
3777+ * Licensed under the Apache License, Version 2.0 (the "License");
3778+ * you may not use this file except in compliance with the License.
3779+ * You may obtain a copy of the License at
3780+ *
3781+ *     http://www.apache.org/licenses/LICENSE-2.0
3782+ *
3783+ * Unless required by applicable law or agreed to in writing, software
3784+ * distributed under the License is distributed on an "AS IS" BASIS,
3785+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3786+ * See the License for the specific language governing permissions and
3787+ * limitations under the License.
3788+ */
3789+#ifndef LIBINPUT_EVDEV_PRIVACY_SWITCH_H
3790+#define LIBINPUT_EVDEV_PRIVACY_SWITCH_H
3791+
3792+#include "evdev.h"
3793+#include "libinput-private.h"
3794+
3795+struct privacy_switch {
3796+	uint64_t time;
3797+	enum libinput_switch sw;
3798+	enum libinput_switch_state state;
3799+};
3800+
3801+struct evdev_dispatch* evdev_privacy_switch_create(struct evdev_device* device);
3802+
3803+#endif
3804diff -Naur old/src/evdev-tablet.c new/src/evdev-tablet.c
3805--- old/src/evdev-tablet.c	2024-01-01 00:00:00.000000000 +0800
3806+++ new/src/evdev-tablet.c	2024-01-01 00:00:00.000000000 +0800
3807@@ -220,6 +220,7 @@
3808 	case ABS_TILT_Y:
3809 	case ABS_DISTANCE:
3810 	case ABS_WHEEL:
3811+	case ABS_MT_TOOL_TYPE:
3812 		axis = evcode_to_axis(e->code);
3813 		if (axis == LIBINPUT_TABLET_TOOL_AXIS_NONE) {
3814 			evdev_log_bug_libinput(device,
3815@@ -231,7 +232,6 @@
3816 		tablet->prev_value[axis] = tablet->current_value[axis];
3817 		if (tablet_filter_axis_fuzz(tablet, device, e, axis))
3818 			break;
3819-
3820 		tablet->current_value[axis] = e->value;
3821 		set_bit(tablet->changed_axes, axis);
3822 		tablet_set_status(tablet, TABLET_AXES_UPDATED);
3823@@ -1184,6 +1184,7 @@
3824 			.serial = serial,
3825 			.tool_id = tool_id,
3826 			.refcount = 1,
3827+			.pressure.mt_tool_type = tablet->current_value[LIBINPUT_TABLET_TOOL_AXIS_TYPE],
3828 		};
3829
3830 		tool_set_pressure_thresholds(tablet, tool);
3831@@ -2563,6 +2564,34 @@
3832 	return true;
3833 }
3834
3835+static void
3836+tablet_reset_abs_resolution(struct evdev_device *device)
3837+{
3838+    if (!device->abs.is_fake_resolution) {
3839+        return;
3840+    }
3841+    struct libevdev *evdev = device->evdev;
3842+    const struct input_absinfo *absy;
3843+    const struct input_absinfo *absx;
3844+    size_t widthmm = 271;
3845+    size_t heightmm = 170;
3846+    size_t xres = 0;
3847+    size_t yres = 0;
3848+
3849+    absx = libevdev_get_abs_info(evdev, ABS_X);
3850+    absy = libevdev_get_abs_info(evdev, ABS_Y);
3851+    xres = (absx->maximum - absx->minimum) / widthmm;
3852+    yres = (absy->maximum - absy->minimum) / heightmm;
3853+    if (xres == 0 || yres == 0) {
3854+        return;
3855+    }
3856+    libevdev_set_abs_resolution(evdev, ABS_X, xres);
3857+    libevdev_set_abs_resolution(evdev, ABS_Y, yres);
3858+    device->abs.is_fake_resolution = false;
3859+    libinput_log_printf("\t\tdevice:%s no resolution or size hints, assuming a size of %dx%d mm\n",
3860+        device->devname, widthmm, heightmm);
3861+}
3862+
3863 static int
3864 tablet_init(struct tablet_dispatch *tablet,
3865 	    struct evdev_device *device)
3866@@ -2577,6 +2606,7 @@
3867 	tablet->status = TABLET_NONE;
3868 	tablet->current_tool.type = LIBINPUT_TOOL_NONE;
3869 	list_init(&tablet->tool_list);
3870+    tablet_reset_abs_resolution(device);
3871
3872 	if (tablet_reject_device(device))
3873 		return -1;
3874diff -Naur old/src/evdev-tablet.h new/src/evdev-tablet.h
3875--- old/src/evdev-tablet.h	2024-01-01 00:00:00.000000000 +0800
3876+++ new/src/evdev-tablet.h	2024-01-01 00:00:00.000000000 +0800
3877@@ -152,6 +152,9 @@
3878 	case ABS_WHEEL:
3879 		axis = LIBINPUT_TABLET_TOOL_AXIS_SLIDER;
3880 		break;
3881+	case ABS_MT_TOOL_TYPE:
3882+		axis = LIBINPUT_TABLET_TOOL_AXIS_TYPE;
3883+		break;
3884 	default:
3885 		axis = LIBINPUT_TABLET_TOOL_AXIS_NONE;
3886 		break;
3887@@ -210,6 +213,9 @@
3888 	case LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR:
3889 		evcode = ABS_MT_TOUCH_MAJOR;
3890 		break;
3891+	case LIBINPUT_TABLET_TOOL_AXIS_TYPE:
3892+		evcode = ABS_MT_TOOL_TYPE;
3893+		break;
3894 	case LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR:
3895 		evcode = ABS_MT_TOUCH_MINOR;
3896 		break;
3897diff -Naur old/src/libinput.c new/src/libinput.c
3898--- old/src/libinput.c	2024-01-01 00:00:00.000000000 +0800
3899+++ new/src/libinput.c	2024-01-01 00:00:00.000000000 +0800
3900@@ -36,9 +36,12 @@
3901
3902 #include "libinput.h"
3903 #include "libinput-private.h"
3904+#include "evdev-mt-touchpad.h"
3905 #include "evdev.h"
3906 #include "timer.h"
3907 #include "quirks.h"
3908+#include "evdev-joystick.h"
3909+#include "evdev-privacy-switch.h"
3910
3911 #define require_event_type(li_, type_, retval_, ...)	\
3912 	if (type_ == LIBINPUT_EVENT_NONE) abort(); \
3913@@ -84,9 +87,16 @@
3914 	CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED);
3915 	CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED);
3916 	CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY);
3917+	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_TAP);
3918+	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD);
3919+	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
3920+	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN);
3921+	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END);
3922 	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION);
3923 	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
3924 	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON);
3925+        CASE_RETURN_STRING(LIBINPUT_EVENT_JOYSTICK_AXIS);
3926+        CASE_RETURN_STRING(LIBINPUT_EVENT_JOYSTICK_BUTTON);
3927 	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS);
3928 	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_SCROLL_WHEEL);
3929 	CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_SCROLL_FINGER);
3930@@ -96,6 +106,9 @@
3931 	CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION);
3932 	CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL);
3933 	CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME);
3934+        CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCHPAD_DOWN);
3935+        CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCHPAD_UP);
3936+        CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCHPAD_MOTION);
3937 	CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS);
3938 	CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
3939 	CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP);
3940@@ -113,6 +126,7 @@
3941 	CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_HOLD_BEGIN);
3942 	CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_HOLD_END);
3943 	CASE_RETURN_STRING(LIBINPUT_EVENT_SWITCH_TOGGLE);
3944+	CASE_RETURN_STRING(LIBINPUT_EVENT_MSDP);
3945 	case LIBINPUT_EVENT_NONE:
3946 		abort();
3947 	}
3948@@ -193,6 +207,11 @@
3949 	int32_t slot;
3950 	int32_t seat_slot;
3951 	struct device_coords point;
3952+	struct device_coord_rect tool_rect;
3953+	int32_t pressure;
3954+	struct touch_axis axis;
3955+	int32_t tool_type;
3956+	int32_t blob_id;
3957 };
3958
3959 struct libinput_event_gesture {
3960@@ -202,8 +221,10 @@
3961 	int cancelled;
3962 	struct normalized_coords delta;
3963 	struct normalized_coords delta_unaccel;
3964+	struct sloted_coords_info solt_touches;
3965 	double scale;
3966 	double angle;
3967+	struct device_coords coords[5];
3968 };
3969
3970 struct libinput_event_tablet_tool {
3971@@ -217,6 +238,7 @@
3972 	struct libinput_tablet_tool *tool;
3973 	enum libinput_tablet_tool_proximity_state proximity_state;
3974 	enum libinput_tablet_tool_tip_state tip_state;
3975+	int32_t mt_tool_type;
3976 };
3977
3978 struct libinput_event_tablet_pad {
3979@@ -362,6 +384,7 @@
3980 	return event->device;
3981 }
3982
3983+
3984 LIBINPUT_EXPORT struct libinput_event_pointer *
3985 libinput_event_get_pointer_event(struct libinput_event *event)
3986 {
3987@@ -374,7 +397,12 @@
3988 			   LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
3989 			   LIBINPUT_EVENT_POINTER_SCROLL_FINGER,
3990 			   LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
3991-			   LIBINPUT_EVENT_POINTER_AXIS);
3992+			   LIBINPUT_EVENT_POINTER_AXIS,
3993+			   LIBINPUT_EVENT_POINTER_TAP,
3994+			   LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD,
3995+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD,
3996+			   LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN,
3997+			   LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END);
3998
3999 	return (struct libinput_event_pointer *) event;
4000 }
4001@@ -404,6 +432,18 @@
4002 	return (struct libinput_event_touch *) event;
4003 }
4004
4005+LIBINPUT_EXPORT struct libinput_event_touch *
4006+libinput_event_get_touchpad_event(struct libinput_event *event)
4007+{
4008+	require_event_type(libinput_event_get_context(event),
4009+			   event->type,
4010+			   NULL,
4011+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4012+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4013+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4014+	return (struct libinput_event_touch *) event;
4015+}
4016+
4017 LIBINPUT_EXPORT struct libinput_event_gesture *
4018 libinput_event_get_gesture_event(struct libinput_event *event)
4019 {
4020@@ -417,7 +457,10 @@
4021 			   LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
4022 			   LIBINPUT_EVENT_GESTURE_PINCH_END,
4023 			   LIBINPUT_EVENT_GESTURE_HOLD_BEGIN,
4024-			   LIBINPUT_EVENT_GESTURE_HOLD_END);
4025+			   LIBINPUT_EVENT_GESTURE_HOLD_END,
4026+			   LIBINPUT_EVENT_POINTER_TAP,
4027+			   LIBINPUT_EVENT_POINTER_BUTTON,
4028+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
4029
4030 	return (struct libinput_event_gesture *) event;
4031 }
4032@@ -473,6 +516,19 @@
4033 	return (struct libinput_event_switch *) event;
4034 }
4035
4036+LIBINPUT_EXPORT int32_t
4037+libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event)
4038+{
4039+	require_event_type(libinput_event_get_context(&(event->base)),
4040+			   event->base.type,
4041+			   0,
4042+			   LIBINPUT_EVENT_TABLET_TOOL_AXIS,
4043+			   LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
4044+               LIBINPUT_EVENT_TABLET_TOOL_TIP,
4045+			   LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
4046+	return event->mt_tool_type;
4047+}
4048+
4049 LIBINPUT_EXPORT uint32_t
4050 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
4051 {
4052@@ -558,18 +614,37 @@
4053 			   LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
4054 			   LIBINPUT_EVENT_POINTER_SCROLL_FINGER,
4055 			   LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
4056-			   LIBINPUT_EVENT_POINTER_AXIS);
4057+			   LIBINPUT_EVENT_POINTER_AXIS,
4058+			   LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD);
4059
4060 	return event->time;
4061 }
4062
4063+LIBINPUT_EXPORT uint64_t
4064+libinput_event_get_sensortime(struct libinput_event *event)
4065+{
4066+	struct evdev_device *device = evdev_device(event->device);
4067+	int32_t seconds = device->sensor_timestamp.seconds;
4068+	int32_t microseconds = device->sensor_timestamp.microseconds;
4069+	return ((uint64_t)seconds * 1000 * 1000) + microseconds;
4070+}
4071+
4072+LIBINPUT_EXPORT int32_t
4073+libinput_event_get_hand_feature(struct libinput_event *event)
4074+{
4075+	struct evdev_device *device = evdev_device(event->device);
4076+	int32_t value = device->hand_status.hand_feature;
4077+	return value;
4078+}
4079+
4080 LIBINPUT_EXPORT double
4081 libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
4082 {
4083 	require_event_type(libinput_event_get_context(&event->base),
4084 			   event->base.type,
4085 			   0,
4086-			   LIBINPUT_EVENT_POINTER_MOTION);
4087+			   LIBINPUT_EVENT_POINTER_MOTION,
4088+			   LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD);
4089
4090 	return event->delta.x;
4091 }
4092@@ -580,7 +655,8 @@
4093 	require_event_type(libinput_event_get_context(&event->base),
4094 			   event->base.type,
4095 			   0,
4096-			   LIBINPUT_EVENT_POINTER_MOTION);
4097+			   LIBINPUT_EVENT_POINTER_MOTION,
4098+			   LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD);
4099
4100 	return event->delta.y;
4101 }
4102@@ -592,7 +668,8 @@
4103 	require_event_type(libinput_event_get_context(&event->base),
4104 			   event->base.type,
4105 			   0,
4106-			   LIBINPUT_EVENT_POINTER_MOTION);
4107+			   LIBINPUT_EVENT_POINTER_MOTION,
4108+			   LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD);
4109
4110 	return event->delta_raw.x;
4111 }
4112@@ -604,7 +681,8 @@
4113 	require_event_type(libinput_event_get_context(&event->base),
4114 			   event->base.type,
4115 			   0,
4116-			   LIBINPUT_EVENT_POINTER_MOTION);
4117+			   LIBINPUT_EVENT_POINTER_MOTION,
4118+			   LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD);
4119
4120 	return event->delta_raw.y;
4121 }
4122@@ -671,7 +749,9 @@
4123 	require_event_type(libinput_event_get_context(&event->base),
4124 			   event->base.type,
4125 			   0,
4126-			   LIBINPUT_EVENT_POINTER_BUTTON);
4127+			   LIBINPUT_EVENT_POINTER_BUTTON,
4128+			   LIBINPUT_EVENT_POINTER_TAP,
4129+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
4130
4131 	return event->button;
4132 }
4133@@ -682,7 +762,9 @@
4134 	require_event_type(libinput_event_get_context(&event->base),
4135 			   event->base.type,
4136 			   0,
4137-			   LIBINPUT_EVENT_POINTER_BUTTON);
4138+			   LIBINPUT_EVENT_POINTER_BUTTON,
4139+			   LIBINPUT_EVENT_POINTER_TAP,
4140+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
4141
4142 	return event->state;
4143 }
4144@@ -694,11 +776,28 @@
4145 	require_event_type(libinput_event_get_context(&event->base),
4146 			   event->base.type,
4147 			   0,
4148-			   LIBINPUT_EVENT_POINTER_BUTTON);
4149+			   LIBINPUT_EVENT_POINTER_BUTTON,
4150+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
4151
4152 	return event->seat_button_count;
4153 }
4154
4155+LIBINPUT_EXPORT uint32_t
4156+libinput_event_pointer_get_finger_count(
4157+	struct libinput_event_pointer *event)
4158+{
4159+	require_event_type(libinput_event_get_context(&event->base),
4160+			   event->base.type,
4161+			   0,
4162+			   LIBINPUT_EVENT_POINTER_BUTTON,
4163+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
4164+
4165+	struct evdev_device *device = evdev_device(event->base.device);
4166+	struct evdev_dispatch *dispatch = device->dispatch;
4167+	struct tp_dispatch *tp = (struct tp_dispatch *)(dispatch);
4168+
4169+	return tp->nfingers_down;
4170+}
4171 LIBINPUT_EXPORT int
4172 libinput_event_pointer_has_axis(struct libinput_event_pointer *event,
4173 				enum libinput_pointer_axis axis)
4174@@ -930,6 +1029,20 @@
4175 }
4176
4177 LIBINPUT_EXPORT double
4178+libinput_event_touch_get_y(struct libinput_event_touch *event)
4179+{
4180+	struct evdev_device *device = evdev_device(event->base.device);
4181+
4182+	require_event_type(libinput_event_get_context(&event->base),
4183+			   event->base.type,
4184+			   0,
4185+			   LIBINPUT_EVENT_TOUCH_DOWN,
4186+			   LIBINPUT_EVENT_TOUCH_MOTION);
4187+
4188+	return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y);
4189+}
4190+
4191+LIBINPUT_EXPORT double
4192 libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
4193 				       uint32_t height)
4194 {
4195@@ -945,7 +1058,7 @@
4196 }
4197
4198 LIBINPUT_EXPORT double
4199-libinput_event_touch_get_y(struct libinput_event_touch *event)
4200+libinput_event_touch_get_tool_x(struct libinput_event_touch *event)
4201 {
4202 	struct evdev_device *device = evdev_device(event->base.device);
4203
4204@@ -955,9 +1068,358 @@
4205 			   LIBINPUT_EVENT_TOUCH_DOWN,
4206 			   LIBINPUT_EVENT_TOUCH_MOTION);
4207
4208+	return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.x);
4209+}
4210+
4211+LIBINPUT_EXPORT double
4212+libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event,
4213+				       uint32_t width)
4214+{
4215+	struct evdev_device *device = evdev_device(event->base.device);
4216+
4217+	require_event_type(libinput_event_get_context(&event->base),
4218+			   event->base.type,
4219+			   0,
4220+			   LIBINPUT_EVENT_TOUCH_DOWN,
4221+			   LIBINPUT_EVENT_TOUCH_MOTION);
4222+
4223+	return evdev_device_transform_x(device, event->tool_rect.x, width);
4224+}
4225+
4226+LIBINPUT_EXPORT double
4227+libinput_event_touch_get_tool_y(struct libinput_event_touch *event)
4228+{
4229+	struct evdev_device *device = evdev_device(event->base.device);
4230+
4231+	require_event_type(libinput_event_get_context(&event->base),
4232+			   event->base.type,
4233+			   0,
4234+			   LIBINPUT_EVENT_TOUCH_DOWN,
4235+			   LIBINPUT_EVENT_TOUCH_MOTION);
4236+
4237+	return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.y);
4238+}
4239+
4240+LIBINPUT_EXPORT double
4241+libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event,
4242+				       uint32_t height)
4243+{
4244+	struct evdev_device *device = evdev_device(event->base.device);
4245+
4246+	require_event_type(libinput_event_get_context(&event->base),
4247+			   event->base.type,
4248+			   0,
4249+			   LIBINPUT_EVENT_TOUCH_DOWN,
4250+			   LIBINPUT_EVENT_TOUCH_MOTION);
4251+
4252+	return evdev_device_transform_y(device, event->tool_rect.y, height);
4253+}
4254+
4255+LIBINPUT_EXPORT double
4256+libinput_event_touch_get_tool_width(struct libinput_event_touch *event)
4257+{
4258+	struct evdev_device *device = evdev_device(event->base.device);
4259+
4260+	require_event_type(libinput_event_get_context(&event->base),
4261+			   event->base.type,
4262+			   0,
4263+			   LIBINPUT_EVENT_TOUCH_DOWN,
4264+			   LIBINPUT_EVENT_TOUCH_MOTION);
4265+
4266+	return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.w);
4267+}
4268+
4269+LIBINPUT_EXPORT double
4270+libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event,
4271+				       uint32_t width)
4272+{
4273+	struct evdev_device *device = evdev_device(event->base.device);
4274+
4275+	require_event_type(libinput_event_get_context(&event->base),
4276+			   event->base.type,
4277+			   0,
4278+			   LIBINPUT_EVENT_TOUCH_DOWN,
4279+			   LIBINPUT_EVENT_TOUCH_MOTION);
4280+
4281+	return evdev_device_transform_x(device, event->tool_rect.w, width);
4282+}
4283+
4284+LIBINPUT_EXPORT double
4285+libinput_event_touch_get_tool_height(struct libinput_event_touch *event)
4286+{
4287+	struct evdev_device *device = evdev_device(event->base.device);
4288+
4289+	require_event_type(libinput_event_get_context(&event->base),
4290+			   event->base.type,
4291+			   0,
4292+			   LIBINPUT_EVENT_TOUCH_DOWN,
4293+			   LIBINPUT_EVENT_TOUCH_MOTION);
4294+
4295+	return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.h);
4296+}
4297+
4298+LIBINPUT_EXPORT double
4299+libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event,
4300+				       uint32_t height)
4301+{
4302+	struct evdev_device *device = evdev_device(event->base.device);
4303+
4304+	require_event_type(libinput_event_get_context(&event->base),
4305+			   event->base.type,
4306+			   0,
4307+			   LIBINPUT_EVENT_TOUCH_DOWN,
4308+			   LIBINPUT_EVENT_TOUCH_MOTION);
4309+
4310+	return evdev_device_transform_y(device, event->tool_rect.h, height);
4311+}
4312+
4313+LIBINPUT_EXPORT uint32_t
4314+libinput_event_touchpad_get_time(struct libinput_event_touch *event)
4315+{
4316+	require_event_type(libinput_event_get_context(&event->base),
4317+			   event->base.type,
4318+			   0,
4319+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4320+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4321+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4322+
4323+	return us2ms(event->time);
4324+}
4325+
4326+LIBINPUT_EXPORT uint64_t
4327+libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event)
4328+{
4329+	require_event_type(libinput_event_get_context(&event->base),
4330+			   event->base.type,
4331+			   0,
4332+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4333+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4334+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4335+
4336+	return event->time;
4337+}
4338+
4339+LIBINPUT_EXPORT int32_t
4340+libinput_event_touchpad_get_slot(struct libinput_event_touch *event)
4341+{
4342+	require_event_type(libinput_event_get_context(&event->base),
4343+			   event->base.type,
4344+			   0,
4345+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4346+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4347+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4348+
4349+	return event->slot;
4350+}
4351+
4352+LIBINPUT_EXPORT int32_t
4353+libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event)
4354+{
4355+	require_event_type(libinput_event_get_context(&event->base),
4356+			   event->base.type,
4357+			   0,
4358+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4359+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4360+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4361+
4362+	return event->seat_slot;
4363+}
4364+
4365+LIBINPUT_EXPORT double
4366+libinput_event_touchpad_get_x(struct libinput_event_touch *event)
4367+{
4368+	struct evdev_device *device = evdev_device(event->base.device);
4369+
4370+	require_event_type(libinput_event_get_context(&event->base),
4371+			   event->base.type,
4372+			   0,
4373+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4374+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4375+
4376+	return evdev_convert_to_mm(device->abs.absinfo_x, event->point.x);
4377+}
4378+
4379+LIBINPUT_EXPORT double
4380+libinput_event_touchpad_get_y(struct libinput_event_touch *event)
4381+{
4382+	struct evdev_device *device = evdev_device(event->base.device);
4383+
4384+	require_event_type(libinput_event_get_context(&event->base),
4385+			   event->base.type,
4386+			   0,
4387+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4388+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4389+
4390 	return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y);
4391 }
4392
4393+LIBINPUT_EXPORT double
4394+libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event)
4395+{
4396+    struct evdev_device *device = evdev_device(event->base.device);
4397+
4398+    require_event_type(libinput_event_get_context(&event->base),
4399+               event->base.type,
4400+               0,
4401+               LIBINPUT_EVENT_TOUCHPAD_DOWN,
4402+               LIBINPUT_EVENT_TOUCHPAD_MOTION);
4403+
4404+    return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.x);
4405+}
4406+
4407+LIBINPUT_EXPORT double
4408+libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event)
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_TOUCHPAD_DOWN,
4416+               LIBINPUT_EVENT_TOUCHPAD_MOTION);
4417+
4418+    return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.y);
4419+}
4420+
4421+LIBINPUT_EXPORT double
4422+libinput_event_touchpad_get_tool_width(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_TOUCHPAD_DOWN,
4430+               LIBINPUT_EVENT_TOUCHPAD_MOTION);
4431+
4432+    return evdev_convert_to_mm(device->abs.absinfo_x, event->tool_rect.w);
4433+}
4434+
4435+LIBINPUT_EXPORT double
4436+libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event)
4437+{
4438+    struct evdev_device *device = evdev_device(event->base.device);
4439+
4440+    require_event_type(libinput_event_get_context(&event->base),
4441+               event->base.type,
4442+               0,
4443+               LIBINPUT_EVENT_TOUCHPAD_DOWN,
4444+               LIBINPUT_EVENT_TOUCHPAD_MOTION);
4445+
4446+    return evdev_convert_to_mm(device->abs.absinfo_y, event->tool_rect.h);
4447+}
4448+
4449+LIBINPUT_EXPORT double
4450+libinput_event_touchpad_get_pressure(struct libinput_event_touch *event)
4451+{
4452+	require_event_type(libinput_event_get_context(&event->base),
4453+			   event->base.type,
4454+			   0,
4455+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4456+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4457+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4458+
4459+	struct libinput_device* device = libinput_event_get_device(&event->base);
4460+	if (device == NULL) {
4461+		return 0.0;
4462+	}
4463+	struct evdev_device* evDevice = evdev_device(device);
4464+	if (evDevice == NULL) {
4465+		return 0.0;
4466+	}
4467+	double range = evDevice->pressureMax;
4468+	if (range == 0.0) {
4469+		return 0.0;
4470+	}
4471+	double value = event->pressure / range;
4472+	return max(0.0, value);
4473+}
4474+
4475+LIBINPUT_EXPORT int32_t
4476+libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event)
4477+{
4478+    require_event_type(libinput_event_get_context(&event->base),
4479+			   event->base.type,
4480+			   0,
4481+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4482+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4483+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4484+	struct libinput_device* device = libinput_event_get_device(&event->base);
4485+	if (device == NULL) {
4486+		libinput_log_printf("device is nullptr\n");
4487+		return 0;
4488+	}
4489+	struct evdev_device* evDevice = evdev_device(device);
4490+	if (evDevice == NULL) {
4491+		libinput_log_printf("evdev_device is nullptr\n");
4492+		return 0;
4493+	}
4494+	const struct input_absinfo* absInfo = libevdev_get_abs_info(evDevice->evdev, ABS_MT_TOUCH_MAJOR);
4495+	if (absInfo == NULL) {
4496+		libinput_log_printf("ABS_MT_TOUCH_MAJOR absInfo is nullptr\n");
4497+		return 0;
4498+	}
4499+	if (event->axis.major > absInfo->maximum || event->axis.major < 0) {
4500+		libinput_log_printf(" major = %d > absInfo->maximum\n", event->axis.major);
4501+		return 0;
4502+	}
4503+    return event->axis.major;
4504+}
4505+
4506+LIBINPUT_EXPORT int32_t
4507+libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event)
4508+{
4509+    require_event_type(libinput_event_get_context(&event->base),
4510+			   event->base.type,
4511+			   0,
4512+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4513+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4514+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4515+
4516+    struct libinput_device* device = libinput_event_get_device(&event->base);
4517+	if (device == NULL) {
4518+		libinput_log_printf("device is nullptr\n");
4519+		return 0;
4520+	}
4521+	struct evdev_device* evDevice = evdev_device(device);
4522+	if (evDevice == NULL) {
4523+		libinput_log_printf("evdev_device is nullptr\n");
4524+		return 0;
4525+	}
4526+	const struct input_absinfo* absInfo = libevdev_get_abs_info(evDevice->evdev, ABS_MT_TOUCH_MINOR);
4527+	if (absInfo == NULL) {
4528+		libinput_log_printf("ABS_MT_TOUCH_MAJOR absInfo is nullptr\n");
4529+		return 0;
4530+	}
4531+	if (event->axis.minor > absInfo->maximum || event->axis.minor < 0) {
4532+		libinput_log_printf(" major = %d > absInfo->maximum\n", event->axis.minor);
4533+		return 0;
4534+	}
4535+    return event->axis.minor;
4536+}
4537+
4538+LIBINPUT_EXPORT int32_t
4539+libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event)
4540+{
4541+    require_event_type(libinput_event_get_context(&event->base),
4542+			   event->base.type,
4543+			   0,
4544+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
4545+			   LIBINPUT_EVENT_TOUCHPAD_UP,
4546+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
4547+
4548+	return event->tool_type;
4549+}
4550+
4551+LIBINPUT_EXPORT int32_t
4552+libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType)
4553+{
4554+	if (device == NULL) {
4555+		return -1;
4556+	}
4557+	return evdev_device_touchpad_btn_tool_type_down((struct evdev_device *)device, btnToolType);
4558+}
4559+
4560 LIBINPUT_EXPORT uint32_t
4561 libinput_event_gesture_get_time(struct libinput_event_gesture *event)
4562 {
4563@@ -1118,6 +1580,44 @@
4564 }
4565
4566 LIBINPUT_EXPORT int
4567+libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx)
4568+{
4569+	require_event_type(libinput_event_get_context(&event->base),
4570+			   event->base.type,
4571+			   0,
4572+			   LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
4573+			   LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
4574+			   LIBINPUT_EVENT_GESTURE_SWIPE_END);
4575+
4576+	return event->coords[idx].x;
4577+}
4578+
4579+LIBINPUT_EXPORT int
4580+libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx)
4581+{
4582+	require_event_type(libinput_event_get_context(&event->base),
4583+			   event->base.type,
4584+			   0,
4585+			   LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
4586+			   LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
4587+			   LIBINPUT_EVENT_GESTURE_SWIPE_END);
4588+
4589+	return event->coords[idx].y;
4590+}
4591+
4592+LIBINPUT_EXPORT struct sloted_coords_info *
4593+libinput_event_gesture_get_solt_touches(
4594+	struct libinput_event_gesture *event)
4595+{
4596+	require_event_type(libinput_event_get_context(&event->base),
4597+			   event->base.type,
4598+			   NULL,
4599+			   LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
4600+
4601+	return &event->solt_touches;
4602+}
4603+
4604+LIBINPUT_EXPORT int
4605 libinput_event_tablet_tool_x_has_changed(
4606 				struct libinput_event_tablet_tool *event)
4607 {
4608@@ -1134,6 +1634,24 @@
4609 }
4610
4611 LIBINPUT_EXPORT int
4612+libinput_has_event_led_type(struct libinput_device *device)
4613+{
4614+    return evdev_has_event_type((struct evdev_device *)device, EV_LED);
4615+}
4616+
4617+LIBINPUT_EXPORT int
4618+libinput_get_funckey_state(struct libinput_device *device,  unsigned int code)
4619+{
4620+    return evdev_get_event_value((struct evdev_device *)device, EV_LED, code);
4621+}
4622+
4623+LIBINPUT_EXPORT int
4624+libinput_set_led_state(struct libinput_device *device, unsigned int code, unsigned int state)
4625+{
4626+    return evdev_kernel_set_led_value((struct evdev_device *)device, code, state);
4627+}
4628+
4629+LIBINPUT_EXPORT int
4630 libinput_event_tablet_tool_y_has_changed(
4631 				struct libinput_event_tablet_tool *event)
4632 {
4633@@ -1892,11 +2410,8 @@
4634 	/* If we fail, we'll fail next time too */
4635 	libinput->quirks_initialized = true;
4636
4637-	data_path = getenv("LIBINPUT_QUIRKS_DIR");
4638-	if (!data_path) {
4639-		data_path = LIBINPUT_QUIRKS_DIR;
4640-		override_file = LIBINPUT_QUIRKS_OVERRIDE_FILE;
4641-	}
4642+		data_path = (char *)LIBINPUT_QUIRKS_DIR;
4643+		override_file = (char *)LIBINPUT_QUIRKS_OVERRIDE_FILE;
4644
4645 	quirks = quirks_init_subsystem(data_path,
4646 				       override_file,
4647@@ -2396,6 +2911,9 @@
4648 	case LIBINPUT_DEVICE_CAP_SWITCH:
4649 		capability = "CAP_SWITCH";
4650 		break;
4651+	case LIBINPUT_DEVICE_CAP_JOYSTICK:
4652+        capability = "CAP_JOYSTICK";
4653+        break;
4654 	}
4655
4656 	log_bug_libinput(device->seat->libinput,
4657@@ -2459,6 +2977,30 @@
4658 }
4659
4660 void
4661+touchpad_pointer_notify_motion(struct libinput_device *device,
4662+		      uint64_t time,
4663+		      const struct normalized_coords *delta,
4664+		      const struct device_float_coords *raw)
4665+{
4666+	struct libinput_event_pointer *motion_event;
4667+
4668+	if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
4669+		return;
4670+
4671+	motion_event = zalloc(sizeof *motion_event);
4672+
4673+	*motion_event = (struct libinput_event_pointer) {
4674+		.time = time,
4675+		.delta = *delta,
4676+		.delta_raw = *raw,
4677+	};
4678+
4679+	post_device_event(device, time,
4680+			  LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD,
4681+			  &motion_event->base);
4682+}
4683+
4684+void
4685 pointer_notify_motion_absolute(struct libinput_device *device,
4686 			       uint64_t time,
4687 			       const struct device_coords *point)
4688@@ -2511,6 +3053,94 @@
4689 }
4690
4691 void
4692+pointer_notify_button_touchpad(struct libinput_device *device,
4693+		      uint64_t time,
4694+		      int32_t button,
4695+		      enum libinput_button_state state)
4696+{
4697+	struct libinput_event_pointer *button_event;
4698+	int32_t seat_button_count;
4699+
4700+	if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
4701+		return;
4702+
4703+	button_event = zalloc(sizeof *button_event);
4704+
4705+	seat_button_count = update_seat_button_count(device->seat,
4706+						     button,
4707+						     state);
4708+
4709+	*button_event = (struct libinput_event_pointer) {
4710+		.time = time,
4711+		.button = button,
4712+		.state = state,
4713+		.seat_button_count = seat_button_count,
4714+	};
4715+
4716+	post_device_event(device, time,
4717+			  LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD,
4718+			  &button_event->base);
4719+}
4720+
4721+void
4722+pointer_notify_tap(struct libinput_device *device,
4723+		      uint64_t time,
4724+		      int32_t button,
4725+		      enum libinput_button_state state)
4726+{
4727+	struct libinput_event_pointer *button_event;
4728+	int32_t seat_button_count;
4729+
4730+	if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
4731+		return;
4732+
4733+	button_event = zalloc(sizeof *button_event);
4734+
4735+	seat_button_count = update_seat_button_count(device->seat,
4736+						     button,
4737+						     state);
4738+
4739+	*button_event = (struct libinput_event_pointer) {
4740+		.time = time,
4741+		.button = button,
4742+		.state = state,
4743+		.seat_button_count = seat_button_count,
4744+	};
4745+
4746+	post_device_event(device, time,
4747+			  LIBINPUT_EVENT_POINTER_TAP,
4748+			  &button_event->base);
4749+}
4750+
4751+void
4752+gesture_notify_axis_finger(struct libinput_device *device,
4753+			  uint64_t time,
4754+			  enum libinput_event_type type,
4755+			  uint32_t axes,
4756+			  const struct normalized_coords *delta)
4757+{
4758+	struct libinput_event_pointer *axis_event;
4759+	const struct discrete_coords zero_discrete = {0};
4760+	const struct wheel_v120 zero_v120 = {0};
4761+
4762+	if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
4763+		return;
4764+
4765+	axis_event = zalloc(sizeof *axis_event);
4766+
4767+	*axis_event = (struct libinput_event_pointer) {
4768+		.time = time,
4769+		.delta = *delta,
4770+		.source = LIBINPUT_POINTER_AXIS_SOURCE_FINGER,
4771+		.axes = axes,
4772+		.discrete = zero_discrete,
4773+		.v120 = zero_v120,
4774+	};
4775+
4776+	post_device_event(device, time, type, &axis_event->base);
4777+}
4778+
4779+void
4780 pointer_notify_axis_finger(struct libinput_device *device,
4781 			  uint64_t time,
4782 			  uint32_t axes,
4783@@ -2639,11 +3269,33 @@
4784 }
4785
4786 void
4787+touch_notify_msdp(struct libinput_device *device,
4788+			uint64_t time)
4789+{
4790+	struct libinput_event_touch *touch_event;
4791+
4792+	touch_event = zalloc(sizeof *touch_event);
4793+
4794+	*touch_event = (struct libinput_event_touch) {
4795+		.time = time,
4796+	};
4797+
4798+	post_device_event(device, time,
4799+			  LIBINPUT_EVENT_MSDP,
4800+			  &touch_event->base);
4801+}
4802+
4803+void
4804 touch_notify_touch_down(struct libinput_device *device,
4805 			uint64_t time,
4806 			int32_t slot,
4807 			int32_t seat_slot,
4808-			const struct device_coords *point)
4809+			int32_t pressure,
4810+			const struct extra_data *extraData,
4811+            const struct touch_axis *axis,
4812+			const struct device_coords *point,
4813+			int32_t tool_type,
4814+			const struct device_coord_rect *tool_rect)
4815 {
4816 	struct libinput_event_touch *touch_event;
4817
4818@@ -2657,6 +3309,11 @@
4819 		.slot = slot,
4820 		.seat_slot = seat_slot,
4821 		.point = *point,
4822+		.tool_rect = *tool_rect,
4823+		.pressure = pressure,
4824+		.blob_id = extraData->blob_id,
4825+		.axis = *axis,
4826+		.tool_type = tool_type,
4827 	};
4828
4829 	post_device_event(device, time,
4830@@ -2669,7 +3326,12 @@
4831 			  uint64_t time,
4832 			  int32_t slot,
4833 			  int32_t seat_slot,
4834-			  const struct device_coords *point)
4835+			  int32_t pressure,
4836+			  const struct extra_data *extraData,
4837+              const struct touch_axis *axis,
4838+			  const struct device_coords *point,
4839+			  int32_t tool_type,
4840+			  const struct device_coord_rect *tool_rect)
4841 {
4842 	struct libinput_event_touch *touch_event;
4843
4844@@ -2683,6 +3345,11 @@
4845 		.slot = slot,
4846 		.seat_slot = seat_slot,
4847 		.point = *point,
4848+		.tool_rect = *tool_rect,
4849+		.pressure = pressure,
4850+		.axis = *axis,
4851+		.tool_type = tool_type,
4852+		.blob_id = extraData->blob_id,
4853 	};
4854
4855 	post_device_event(device, time,
4856@@ -2694,7 +3361,8 @@
4857 touch_notify_touch_up(struct libinput_device *device,
4858 		      uint64_t time,
4859 		      int32_t slot,
4860-		      int32_t seat_slot)
4861+		      int32_t seat_slot,
4862+		      int32_t tool_type)
4863 {
4864 	struct libinput_event_touch *touch_event;
4865
4866@@ -2707,6 +3375,7 @@
4867 		.time = time,
4868 		.slot = slot,
4869 		.seat_slot = seat_slot,
4870+		.tool_type = tool_type,
4871 	};
4872
4873 	post_device_event(device, time,
4874@@ -2759,6 +3428,90 @@
4875 }
4876
4877 void
4878+touchpad_notify_touch_down(struct libinput_device *device,
4879+			uint64_t time,
4880+			int32_t slot,
4881+			int32_t seat_slot,
4882+			int32_t pressure,
4883+			int32_t tool_type,
4884+			struct touch_axis axis,
4885+			const struct device_coords *point,
4886+			const struct device_coord_rect *tool_rect)
4887+{
4888+	struct libinput_event_touch *touch_event;
4889+	touch_event = zalloc(sizeof *touch_event);
4890+
4891+	*touch_event = (struct libinput_event_touch) {
4892+		.time = time,
4893+		.slot = slot,
4894+		.seat_slot = seat_slot,
4895+		.point = *point,
4896+		.tool_rect = *tool_rect,
4897+		.pressure = pressure,
4898+		.axis = axis,
4899+		.tool_type = tool_type,
4900+	};
4901+
4902+	post_device_event(device, time,
4903+			  LIBINPUT_EVENT_TOUCHPAD_DOWN,
4904+			  &touch_event->base);
4905+}
4906+
4907+void
4908+touchpad_notify_touch_motion(struct libinput_device *device,
4909+			  uint64_t time,
4910+			  int32_t slot,
4911+			  int32_t seat_slot,
4912+			  int32_t pressure,
4913+			  int32_t tool_type,
4914+			  struct touch_axis axis,
4915+			  const struct device_coords *point,
4916+			  const struct device_coord_rect *tool_rect)
4917+{
4918+	struct libinput_event_touch *touch_event;
4919+	touch_event = zalloc(sizeof *touch_event);
4920+
4921+	*touch_event = (struct libinput_event_touch) {
4922+		.time = time,
4923+		.slot = slot,
4924+		.seat_slot = seat_slot,
4925+		.point = *point,
4926+		.tool_rect = *tool_rect,
4927+		.axis = axis,
4928+		.pressure = pressure,
4929+		.tool_type = tool_type,
4930+	};
4931+
4932+	post_device_event(device, time,
4933+			  LIBINPUT_EVENT_TOUCHPAD_MOTION,
4934+			  &touch_event->base);
4935+}
4936+
4937+void
4938+touchpad_notify_touch_up(struct libinput_device *device,
4939+		      uint64_t time,
4940+		      int32_t slot,
4941+		      int32_t seat_slot,
4942+		      int32_t tool_type,
4943+			  struct touch_axis axis)
4944+{
4945+	struct libinput_event_touch *touch_event;
4946+	touch_event = zalloc(sizeof *touch_event);
4947+
4948+	*touch_event = (struct libinput_event_touch) {
4949+		.time = time,
4950+		.slot = slot,
4951+		.seat_slot = seat_slot,
4952+		.axis = axis,
4953+		.tool_type = tool_type,
4954+	};
4955+
4956+	post_device_event(device, time,
4957+			  LIBINPUT_EVENT_TOUCHPAD_UP,
4958+			  &touch_event->base);
4959+}
4960+
4961+void
4962 tablet_notify_axis(struct libinput_device *device,
4963 		   uint64_t time,
4964 		   struct libinput_tablet_tool *tool,
4965@@ -2776,6 +3529,7 @@
4966 		.proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
4967 		.tip_state = tip_state,
4968 		.axes = *axes,
4969+		.mt_tool_type = tool->pressure.mt_tool_type,
4970 	};
4971
4972 	memcpy(axis_event->changed_axes,
4973@@ -2806,6 +3560,7 @@
4974 		.tip_state = LIBINPUT_TABLET_TOOL_TIP_UP,
4975 		.proximity_state = proximity_state,
4976 		.axes = *axes,
4977+		.mt_tool_type = tool->pressure.mt_tool_type,
4978 	};
4979 	memcpy(proximity_event->changed_axes,
4980 	       changed_axes,
4981@@ -2835,6 +3590,7 @@
4982 		.tip_state = tip_state,
4983 		.proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
4984 		.axes = *axes,
4985+		.mt_tool_type = tool->pressure.mt_tool_type,
4986 	};
4987 	memcpy(tip_event->changed_axes,
4988 	       changed_axes,
4989@@ -2873,6 +3629,7 @@
4990 		.proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
4991 		.tip_state = tip_state,
4992 		.axes = *axes,
4993+		.mt_tool_type = tool->pressure.mt_tool_type,
4994 	};
4995
4996 	post_device_event(device,
4997@@ -2999,6 +3756,7 @@
4998 	       bool cancelled,
4999 	       const struct normalized_coords *delta,
5000 	       const struct normalized_coords *unaccel,
5001+	       const struct sloted_coords_info *solt_touches,
5002 	       double scale,
5003 	       double angle)
5004 {
5005@@ -3019,6 +3777,48 @@
5006 		.angle = angle,
5007 	};
5008
5009+	if (solt_touches != NULL) {
5010+		gesture_event->solt_touches = *solt_touches;
5011+	} else {
5012+        memset(&gesture_event->solt_touches, 0, sizeof(struct sloted_coords_info));
5013+    }
5014+
5015+	post_device_event(device, time, type,
5016+			  &gesture_event->base);
5017+}
5018+
5019+static void
5020+gesture_notify_private(struct libinput_device *device,
5021+	       uint64_t time,
5022+	       enum libinput_event_type type,
5023+	       int finger_count,
5024+	       int cancelled,
5025+	       const struct normalized_coords *delta,
5026+	       const struct normalized_coords *unaccel,
5027+	       double scale,
5028+	       double angle,
5029+		   struct device_coords *coords,
5030+		   int coordsLen)
5031+{
5032+	struct libinput_event_gesture *gesture_event;
5033+
5034+	if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_GESTURE))
5035+		return;
5036+
5037+	gesture_event = zalloc(sizeof *gesture_event);
5038+
5039+	*gesture_event = (struct libinput_event_gesture) {
5040+		.time = time,
5041+		.finger_count = finger_count,
5042+		.cancelled = cancelled,
5043+		.delta = *delta,
5044+		.delta_unaccel = *unaccel,
5045+		.scale = scale,
5046+		.angle = angle,
5047+	};
5048+
5049+	memcpy(gesture_event->coords, coords, coordsLen * sizeof(struct device_coords));
5050+
5051 	post_device_event(device, time, type,
5052 			  &gesture_event->base);
5053 }
5054@@ -3029,13 +3829,28 @@
5055 		     enum libinput_event_type type,
5056 		     int finger_count,
5057 		     const struct normalized_coords *delta,
5058-		     const struct normalized_coords *unaccel)
5059+		     const struct normalized_coords *unaccel,
5060+		     const struct sloted_coords_info *solt_touches)
5061 {
5062-	gesture_notify(device, time, type, finger_count, 0, delta, unaccel,
5063+	gesture_notify(device, time, type, finger_count, 0, delta, unaccel, solt_touches,
5064 		       0.0, 0.0);
5065 }
5066
5067 void
5068+gesture_notify_swipe_private(struct libinput_device *device,
5069+		     uint64_t time,
5070+		     enum libinput_event_type type,
5071+		     int finger_count,
5072+		     const struct normalized_coords *delta,
5073+		     const struct normalized_coords *unaccel,
5074+		     struct device_coords *coords,
5075+		     int coordsLen)
5076+{
5077+	gesture_notify_private(device, time, type, finger_count, 0, delta, unaccel,
5078+		       0.0, 0.0, coords, coordsLen);
5079+}
5080+
5081+void
5082 gesture_notify_swipe_end(struct libinput_device *device,
5083 			 uint64_t time,
5084 			 int finger_count,
5085@@ -3044,7 +3859,7 @@
5086 	const struct normalized_coords zero = { 0.0, 0.0 };
5087
5088 	gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_SWIPE_END,
5089-		       finger_count, cancelled, &zero, &zero, 0.0, 0.0);
5090+		       finger_count, cancelled, &zero, &zero, NULL, 0.0, 0.0);
5091 }
5092
5093 void
5094@@ -3058,7 +3873,7 @@
5095 		     double angle)
5096 {
5097 	gesture_notify(device, time, type, finger_count, 0,
5098-		       delta, unaccel, scale, angle);
5099+		       delta, unaccel, NULL, scale, angle);
5100 }
5101
5102 void
5103@@ -3071,7 +3886,7 @@
5104 	const struct normalized_coords zero = { 0.0, 0.0 };
5105
5106 	gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_PINCH_END,
5107-		       finger_count, cancelled, &zero, &zero, scale, 0.0);
5108+		       finger_count, cancelled, &zero, &zero, NULL, scale, 0.0);
5109 }
5110
5111 void
5112@@ -3082,7 +3897,7 @@
5113 	const struct normalized_coords zero = { 0.0, 0.0 };
5114
5115 	gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN,
5116-		       finger_count, 0, &zero, &zero, 0.0, 0.0);
5117+		       finger_count, 0, &zero, &zero, NULL, 0.0, 0.0);
5118 }
5119
5120 void
5121@@ -3094,7 +3909,7 @@
5122 	const struct normalized_coords zero = { 0.0, 0.0 };
5123
5124 	gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_HOLD_END,
5125-		       finger_count, cancelled, &zero, &zero, 0, 0.0);
5126+		       finger_count, cancelled, &zero, &zero, NULL, 0, 0.0);
5127 }
5128
5129 void
5130@@ -3127,6 +3942,63 @@
5131 #endif
5132 }
5133
5134+void
5135+joysticks_notify_axis(struct libinput_device *device,
5136+		    uint64_t time,
5137+		    uint32_t axes,
5138+			const struct joystick_axis_abs_infos *axis_abs)
5139+{
5140+	struct libinput_event_joystick_axis* joystick_axis_event;
5141+
5142+	joystick_axis_event = zalloc(sizeof * joystick_axis_event);
5143+
5144+	*joystick_axis_event = (struct libinput_event_joystick_axis){
5145+		.type = EV_ABS,
5146+		.time = time,
5147+		.axis_value_mask = axes,
5148+		.abs_throttle = axis_abs->abs_throttle,
5149+		.abs_hat0x = axis_abs->abs_hat0x,
5150+		.abs_hat0y = axis_abs->abs_hat0y,
5151+		.abs_x = axis_abs->abs_x,
5152+		.abs_y = axis_abs->abs_y,
5153+		.abs_z = axis_abs->abs_z,
5154+		.abs_rx = axis_abs->abs_rx,
5155+		.abs_ry = axis_abs->abs_ry,
5156+		.abs_rz = axis_abs->abs_rz,
5157+		.abs_gas = axis_abs->abs_gas,
5158+		.abs_brake = axis_abs->abs_brake,
5159+	};
5160+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_x.code, axis_abs->abs_x.value);
5161+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_y.code, axis_abs->abs_y.value);
5162+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_z.code, axis_abs->abs_z.value);
5163+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_rz.code, axis_abs->abs_rz.value);
5164+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_gas.code, axis_abs->abs_gas.value);
5165+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_brake.code, axis_abs->abs_brake.value);
5166+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_hat0x.code, axis_abs->abs_hat0x.value);
5167+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_hat0y.code, axis_abs->abs_hat0y.value);
5168+    libinput_log_printf("code:%d value:%d \r\n", axis_abs->abs_throttle.code, axis_abs->abs_throttle.value);
5169+	post_device_event(device, time,
5170+			  LIBINPUT_EVENT_JOYSTICK_AXIS,
5171+			  &joystick_axis_event->base);
5172+}
5173+
5174+void privacy_switch_notify_event(struct libinput_device *device, uint64_t time, struct privacy_switch* ev_switch)
5175+{
5176+	struct libinput_event_switch *switch_event;
5177+
5178+	switch_event = zalloc(sizeof *switch_event);
5179+
5180+	*switch_event = (struct libinput_event_switch) {
5181+		.time = ev_switch->time,
5182+		.sw = ev_switch->sw,
5183+		.state = ev_switch->state,
5184+	};
5185+
5186+	post_device_event(device, time,
5187+			  LIBINPUT_EVENT_SWITCH_TOGGLE,
5188+			  &switch_event->base);
5189+}
5190+
5191 static void
5192 libinput_post_event(struct libinput *libinput,
5193 		    struct libinput_event *event)
5194@@ -3180,6 +4052,96 @@
5195 	libinput->events_in = (libinput->events_in + 1) % libinput->events_len;
5196 }
5197
5198+
5199+LIBINPUT_EXPORT void
5200+libinput_post_handle_event(struct libinput* libinput, struct libinput_event* event)
5201+{
5202+	libinput_post_event(libinput, event);
5203+}
5204+
5205+LIBINPUT_EXPORT struct libinput_event_joystick_button*
5206+libinput_event_get_joystick_button_event(struct libinput_event* event)
5207+{
5208+    require_event_type(libinput_event_get_context(event),
5209+        event->type,
5210+        NULL,
5211+        LIBINPUT_EVENT_JOYSTICK_BUTTON);
5212+
5213+    return (struct libinput_event_joystick_button*)event;
5214+}
5215+
5216+LIBINPUT_EXPORT struct libinput_event_joystick_axis*
5217+libinput_event_get_joystick_axis_event(struct libinput_event* event)
5218+{
5219+	require_event_type(libinput_event_get_context(event),
5220+        event->type,
5221+        NULL,
5222+        LIBINPUT_EVENT_JOYSTICK_AXIS);
5223+
5224+    return (struct libinput_event_joystick_axis*)event;
5225+}
5226+
5227+/**
5228+ * @brief 获取joystick指定轴的数据是否变化
5229+*/
5230+int32_t libinput_event_get_joystick_axis_value_is_changed(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis)
5231+{
5232+	if (event == NULL) {
5233+		return 0;
5234+	}
5235+
5236+	return (event->axis_value_mask & (uint32_t)axis);
5237+}
5238+
5239+/**
5240+ * @brief 获取轴事件的时间
5241+ */
5242+uint64_t
5243+libinput_event_get_joystick_axis_time(struct libinput_event_joystick_axis *event)
5244+{
5245+	if (event == NULL) {
5246+		return 0;
5247+	}
5248+
5249+	return event->time;
5250+}
5251+
5252+/**
5253+ * @brief 获取joystick指定轴的abs信息
5254+*/
5255+struct libinput_event_joystick_axis_abs_info *
5256+libinput_event_get_joystick_axis_abs_info(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis)
5257+{
5258+	switch (axis) {
5259+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X:
5260+	return &event->abs_x;
5261+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y:
5262+	return &event->abs_y;
5263+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z:
5264+	return &event->abs_z;
5265+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX:
5266+	return &event->abs_rx;
5267+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY:
5268+	return &event->abs_ry;
5269+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ:
5270+	return &event->abs_rz;
5271+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE:
5272+	return &event->abs_throttle;
5273+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X:
5274+	return &event->abs_hat0x;
5275+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y:
5276+	return &event->abs_hat0y;
5277+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS:
5278+	return &event->abs_gas;
5279+	case LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE:
5280+	return &event->abs_brake;
5281+	default:
5282+	break;
5283+	}
5284+
5285+	return NULL;
5286+}
5287+
5288 LIBINPUT_EXPORT struct libinput_event *
5289 libinput_get_event(struct libinput *libinput)
5290 {
5291@@ -3263,12 +4225,169 @@
5292 	return evdev_device_get_sysname((struct evdev_device *) device);
5293 }
5294
5295+LIBINPUT_EXPORT const char*
5296+libinput_device_get_phys(struct libinput_device* device)
5297+{
5298+	struct libevdev* evdev = ((struct evdev_device*)device)->evdev;
5299+	if (evdev == NULL) {
5300+		return NULL;
5301+	}
5302+	return libevdev_get_phys(evdev);
5303+}
5304+
5305+LIBINPUT_EXPORT const char*
5306+libinput_device_get_uniq(struct libinput_device* device)
5307+{
5308+	struct libevdev* evdev = ((struct evdev_device*)device)->evdev;
5309+	if (evdev == NULL) {
5310+		return NULL;
5311+	}
5312+	return libevdev_get_uniq(evdev);
5313+}
5314+
5315 LIBINPUT_EXPORT const char *
5316 libinput_device_get_name(struct libinput_device *device)
5317 {
5318 	return evdev_device_get_name((struct evdev_device *) device);
5319 }
5320
5321+LIBINPUT_EXPORT enum evdev_device_udev_tags
5322+libinput_device_get_tags(struct libinput_device* device)
5323+{
5324+	if(device == NULL)
5325+	{
5326+		return EVDEV_UDEV_TAG_INPUT;
5327+	}
5328+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5329+	enum evdev_device_udev_tags udev_tags;
5330+	udev_tags = evdev_device_get_udev_device_tags(evdevDevice);
5331+    return udev_tags;
5332+}
5333+
5334+LIBINPUT_EXPORT int32_t
5335+libinput_device_has_key(struct libinput_device* device, int32_t keyCode)
5336+{
5337+	if(device == NULL)
5338+	{
5339+		return EVDEV_UDEV_TAG_INPUT;
5340+	}
5341+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5342+	if (!libevdev_has_event_type(evdevDevice->evdev, EV_KEY)) {
5343+		return 0;
5344+	}
5345+	if (libevdev_has_event_code(evdevDevice->evdev, EV_KEY, keyCode)) {
5346+		return 1;
5347+	}
5348+	return 0;
5349+}
5350+
5351+LIBINPUT_EXPORT int32_t
5352+libinput_device_get_axis_min(struct libinput_device* device, int32_t code)
5353+{
5354+	if(device == NULL)
5355+	{
5356+		return -1;
5357+	}
5358+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5359+	if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) {
5360+		return -1;
5361+	}
5362+	const struct input_absinfo *absinfo;
5363+	if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) {
5364+		absinfo = libevdev_get_abs_info(evdevDevice->evdev, code);
5365+		return absinfo->minimum;
5366+	}
5367+	return -1;
5368+}
5369+
5370+LIBINPUT_EXPORT int32_t
5371+libinput_device_get_axis_max(struct libinput_device* device, int32_t code)
5372+{
5373+	if(device == NULL)
5374+	{
5375+		return -1;
5376+	}
5377+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5378+	if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) {
5379+		return -1;
5380+	}
5381+	const struct input_absinfo *absinfo;
5382+	if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) {
5383+		absinfo = libevdev_get_abs_info(evdevDevice->evdev, code);
5384+		return absinfo->maximum;
5385+	}
5386+	return -1;
5387+}
5388+
5389+LIBINPUT_EXPORT int32_t
5390+libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code)
5391+{
5392+	if(device == NULL)
5393+	{
5394+		return -1;
5395+	}
5396+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5397+	if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) {
5398+		return -1;
5399+	}
5400+	const struct input_absinfo *absinfo;
5401+	if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) {
5402+		absinfo = libevdev_get_abs_info(evdevDevice->evdev, code);
5403+		return absinfo->fuzz;
5404+	}
5405+	return -1;
5406+}
5407+
5408+LIBINPUT_EXPORT int32_t
5409+libinput_device_get_axis_flat(struct libinput_device* device, int32_t code)
5410+{
5411+	if(device == NULL)
5412+	{
5413+		return -1;
5414+	}
5415+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5416+	if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) {
5417+		return -1;
5418+	}
5419+	const struct input_absinfo *absinfo;
5420+	if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) {
5421+		absinfo = libevdev_get_abs_info(evdevDevice->evdev, code);
5422+		return absinfo->flat;
5423+	}
5424+	return -1;
5425+}
5426+
5427+LIBINPUT_EXPORT int32_t
5428+libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code)
5429+{
5430+	if(device == NULL)
5431+	{
5432+		return -1;
5433+	}
5434+	struct evdev_device* evdevDevice = (struct evdev_device*)device;
5435+	if (!libevdev_has_event_type(evdevDevice->evdev, EV_ABS)) {
5436+		return -1;
5437+	}
5438+	const struct input_absinfo *absinfo;
5439+	if (libevdev_has_event_code(evdevDevice->evdev, EV_ABS, code)) {
5440+		absinfo = libevdev_get_abs_info(evdevDevice->evdev, code);
5441+		return absinfo->resolution;
5442+	}
5443+	return -1;
5444+}
5445+
5446+LIBINPUT_EXPORT unsigned int
5447+libinput_device_get_id_bustype(struct libinput_device* device)
5448+{
5449+	return evdev_device_get_id_bustype((struct evdev_device *) device);
5450+}
5451+
5452+LIBINPUT_EXPORT unsigned int
5453+libinput_device_get_id_version(struct libinput_device* device)
5454+{
5455+	return evdev_device_get_id_version((struct evdev_device *) device);
5456+}
5457+
5458 LIBINPUT_EXPORT unsigned int
5459 libinput_device_get_id_product(struct libinput_device *device)
5460 {
5461@@ -3356,6 +4475,15 @@
5462 }
5463
5464 LIBINPUT_EXPORT int
5465+libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType)
5466+{
5467+	if (device == NULL) {
5468+		return -1;
5469+	}
5470+	return evdev_device_touch_btn_tool_type_down((struct evdev_device *)device, btnToolType);
5471+}
5472+
5473+LIBINPUT_EXPORT int
5474 libinput_device_switch_has_switch(struct libinput_device *device,
5475 				  enum libinput_switch sw)
5476 {
5477@@ -3537,7 +4665,8 @@
5478 			   LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
5479 			   LIBINPUT_EVENT_POINTER_SCROLL_FINGER,
5480 			   LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
5481-			   LIBINPUT_EVENT_POINTER_AXIS);
5482+			   LIBINPUT_EVENT_POINTER_AXIS,
5483+			   LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD);
5484
5485 	return &event->base;
5486 }
5487@@ -3558,6 +4687,19 @@
5488 }
5489
5490 LIBINPUT_EXPORT struct libinput_event *
5491+libinput_event_touchpad_get_base_event(struct libinput_event_touch *event)
5492+{
5493+	require_event_type(libinput_event_get_context(&event->base),
5494+			   event->base.type,
5495+			   NULL,
5496+			   LIBINPUT_EVENT_TOUCHPAD_DOWN,
5497+			   LIBINPUT_EVENT_TOUCHPAD_UP,
5498+			   LIBINPUT_EVENT_TOUCHPAD_MOTION);
5499+
5500+	return &event->base;
5501+}
5502+
5503+LIBINPUT_EXPORT struct libinput_event *
5504 libinput_event_gesture_get_base_event(struct libinput_event_gesture *event)
5505 {
5506 	require_event_type(libinput_event_get_context(&event->base),
5507@@ -4764,3 +5906,177 @@
5508 	}
5509 }
5510 #endif
5511+
5512+LIBINPUT_EXPORT struct libinput_event_joystick_button*
5513+libinput_event_get_joystick_pointer_button_event(struct libinput_event* event)
5514+{
5515+	if (!event)
5516+		return 0;
5517+
5518+	require_event_type(libinput_event_get_context(event),
5519+		event->type,
5520+		NULL,
5521+		LIBINPUT_EVENT_JOYSTICK_BUTTON);
5522+
5523+	return (struct libinput_event_joystick_button*)event;
5524+}
5525+
5526+LIBINPUT_EXPORT uint64_t
5527+libinput_event_joystick_button_time(struct libinput_event_joystick_button* event)
5528+{
5529+    if (!event)
5530+        return 0;
5531+
5532+    require_event_type(libinput_event_get_context(&event->base),
5533+        event->base.type,
5534+        0,
5535+		LIBINPUT_EVENT_JOYSTICK_BUTTON);
5536+
5537+    return event->time;
5538+}
5539+
5540+LIBINPUT_EXPORT uint32_t
5541+libinput_event_joystick_button_get_key(struct libinput_event_joystick_button* event)
5542+{
5543+    if (!event)
5544+        return 0;
5545+
5546+    require_event_type(libinput_event_get_context(&event->base),
5547+		event->base.type,
5548+        0,
5549+		LIBINPUT_EVENT_JOYSTICK_BUTTON);
5550+
5551+    return event->key;
5552+}
5553+
5554+LIBINPUT_EXPORT enum libinput_button_state
5555+libinput_event_joystick_button_get_key_state(struct libinput_event_joystick_button* event)
5556+{
5557+	if (!event)
5558+		return 0;
5559+
5560+	require_event_type(libinput_event_get_context(&event->base),
5561+		event->base.type,
5562+		0,
5563+		LIBINPUT_EVENT_JOYSTICK_BUTTON);
5564+
5565+	return event->state;
5566+}
5567+
5568+LIBINPUT_EXPORT uint32_t
5569+libinput_event_joystick_button_get_seat_key_count(struct libinput_event_joystick_button* event)
5570+{
5571+    if (!event)
5572+        return 0;
5573+
5574+    require_event_type(libinput_event_get_context(&event->base),
5575+		event->base.type,
5576+        0,
5577+		LIBINPUT_EVENT_JOYSTICK_BUTTON);
5578+
5579+    return event->seat_key_count;
5580+}
5581+
5582+LIBINPUT_EXPORT int
5583+libinput_event_joystick_button_get_value(struct libinput_event_joystick_button* event)
5584+{
5585+    if (!event)
5586+        return 0;
5587+
5588+    require_event_type(libinput_event_get_context(&event->base),
5589+		event->base.type,
5590+        0,
5591+        LIBINPUT_EVENT_JOYSTICK_BUTTON);
5592+
5593+    return event->value;
5594+}
5595+
5596+LIBINPUT_EXPORT double
5597+libinput_event_touch_get_pressure(struct libinput_event_touch *event)
5598+{
5599+    require_event_type(libinput_event_get_context(&event->base),
5600+		event->base.type,
5601+		0,
5602+		LIBINPUT_EVENT_TOUCH_DOWN,
5603+		LIBINPUT_EVENT_TOUCH_UP,
5604+		LIBINPUT_EVENT_TOUCH_MOTION,
5605+		LIBINPUT_EVENT_TOUCH_CANCEL,
5606+		LIBINPUT_EVENT_TOUCH_FRAME);
5607+
5608+	struct libinput_device* device = libinput_event_get_device(&event->base);
5609+	if (device == NULL) {
5610+		return 0.0;
5611+	}
5612+	struct evdev_device* evDevice = evdev_device(device);
5613+	if (evDevice == NULL) {
5614+		return 0.0;
5615+	}
5616+
5617+	const struct input_absinfo* absInfo = evDevice->is_mt ? libevdev_get_abs_info(evDevice->evdev, ABS_MT_PRESSURE)
5618+		: libevdev_get_abs_info(evDevice->evdev, ABS_PRESSURE);
5619+	if (!absInfo) {
5620+		return 0.0;
5621+	}
5622+	double range = absInfo->maximum;
5623+	double value = event->pressure / range;
5624+	return max(0.0, value);
5625+}
5626+
5627+LIBINPUT_EXPORT int32_t
5628+libinput_event_touch_get_blob_id(struct libinput_event_touch* event)
5629+{
5630+    require_event_type(libinput_event_get_context(&event->base),
5631+		event->base.type,
5632+		0,
5633+		LIBINPUT_EVENT_TOUCH_DOWN,
5634+		LIBINPUT_EVENT_TOUCH_UP,
5635+		LIBINPUT_EVENT_TOUCH_MOTION,
5636+		LIBINPUT_EVENT_TOUCH_CANCEL,
5637+		LIBINPUT_EVENT_TOUCH_FRAME);
5638+
5639+	return event->blob_id;
5640+}
5641+
5642+LIBINPUT_EXPORT int32_t
5643+libinput_event_touch_get_tool_type(struct libinput_event_touch *event)
5644+{
5645+	require_event_type(libinput_event_get_context(&event->base),
5646+			   event->base.type,
5647+			   0,
5648+			   LIBINPUT_EVENT_TOUCH_DOWN,
5649+			   LIBINPUT_EVENT_TOUCH_UP,
5650+			   LIBINPUT_EVENT_TOUCH_MOTION);
5651+
5652+	return event->tool_type;
5653+}
5654+
5655+LIBINPUT_EXPORT int32_t
5656+libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event)
5657+{
5658+    require_event_type(libinput_event_get_context(&event->base),
5659+                event->base.type,
5660+                0,
5661+                LIBINPUT_EVENT_TOUCH_DOWN,
5662+                LIBINPUT_EVENT_TOUCH_UP,
5663+                LIBINPUT_EVENT_TOUCH_MOTION,
5664+                LIBINPUT_EVENT_TOUCH_CANCEL,
5665+				LIBINPUT_EVENT_TOUCH_FRAME);
5666+
5667+    return event->axis.major;
5668+}
5669+
5670+LIBINPUT_EXPORT int32_t
5671+libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event)
5672+{
5673+    require_event_type(libinput_event_get_context(&event->base),
5674+                event->base.type,
5675+                0,
5676+                LIBINPUT_EVENT_TOUCH_DOWN,
5677+                LIBINPUT_EVENT_TOUCH_UP,
5678+                LIBINPUT_EVENT_TOUCH_MOTION,
5679+                LIBINPUT_EVENT_TOUCH_CANCEL,
5680+				LIBINPUT_EVENT_TOUCH_FRAME);
5681+
5682+    return event->axis.minor;
5683+}
5684+
5685diff -Naur old/src/libinput.h new/src/libinput.h
5686--- old/src/libinput.h	2024-01-01 00:00:00.000000000 +0800
5687+++ new/src/libinput.h	2024-01-01 00:00:00.000000000 +0800
5688@@ -196,6 +196,23 @@
5689 	LIBINPUT_DEVICE_CAP_TABLET_PAD = 4,
5690 	LIBINPUT_DEVICE_CAP_GESTURE = 5,
5691 	LIBINPUT_DEVICE_CAP_SWITCH = 6,
5692+	LIBINPUT_DEVICE_CAP_JOYSTICK = 7,
5693+};
5694+
5695+enum evdev_device_udev_tags {
5696+    EVDEV_UDEV_TAG_INPUT = 1 << 0,
5697+    EVDEV_UDEV_TAG_KEYBOARD = 1 << 1,
5698+    EVDEV_UDEV_TAG_MOUSE = 1 << 2,
5699+    EVDEV_UDEV_TAG_TOUCHPAD = 1 << 3,
5700+    EVDEV_UDEV_TAG_TOUCHSCREEN = 1 << 4,
5701+    EVDEV_UDEV_TAG_TABLET = 1 << 5,
5702+    EVDEV_UDEV_TAG_JOYSTICK = 1 << 6,
5703+    EVDEV_UDEV_TAG_ACCELEROMETER = 1 << 7,
5704+    EVDEV_UDEV_TAG_TABLET_PAD = 1 << 8,
5705+    EVDEV_UDEV_TAG_POINTINGSTICK = 1 << 9,
5706+    EVDEV_UDEV_TAG_TRACKBALL = 1 << 10,
5707+    EVDEV_UDEV_TAG_SWITCH = 1 << 11,
5708+	EVDEV_UDEV_TAG_MSDP = 1 << 12,
5709 };
5710
5711 /**
5712@@ -321,6 +338,49 @@
5713 };
5714
5715 /**
5716+ * @ingroup event_joystick
5717+ *
5718+ * The source for a @ref LIBINPUT_EVENT_POINTER_AXIS event. See
5719+ * libinput_event_get_joystick_axis_event() for details.
5720+ *
5721+ * @since 1.16.4
5722+ */
5723+enum libinput_joystick_axis_source {
5724+	LIBINPUT_JOYSTICK_AXIS_SOURCE_UNKNOWN = 0,
5725+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_X = 1 << 0,
5726+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Y = 1 << 1,
5727+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_Z = 1 << 2,
5728+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RX = 1 << 3,
5729+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RY = 1 << 4,
5730+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RZ = 1 << 5,
5731+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_THROTTLE = 1 << 6,
5732+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_RUDDER = 1 << 7,
5733+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_WHEEL = 1 << 8,
5734+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_GAS = 1 << 9,
5735+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_BRAKE = 1 << 10,
5736+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0X = 1 << 11,
5737+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT0Y = 1 << 12,
5738+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1X = 1 << 13,
5739+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT1Y = 1 << 14,
5740+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2X = 1 << 15,
5741+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT2Y = 1 << 16,
5742+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3X = 1 << 17,
5743+	LIBINPUT_JOYSTICK_AXIS_SOURCE_ABS_HAT3Y = 1 << 18,
5744+};
5745+
5746+#define MAX_SOLTED_COORDS_NUM 10
5747+struct sloted_coords {
5748+	int32_t is_active;
5749+	float x;
5750+	float y;
5751+};
5752+
5753+struct sloted_coords_info {
5754+	struct sloted_coords coords[MAX_SOLTED_COORDS_NUM];
5755+	unsigned int active_count;
5756+};
5757+
5758+/**
5759  * @ingroup device
5760  *
5761  * Available tool types for a device with the @ref
5762@@ -393,6 +453,17 @@
5763 	LIBINPUT_TABLET_TOOL_TIP_DOWN = 1,
5764 };
5765
5766+struct libinput_event_joystick_axis_abs_info {
5767+	int32_t code;
5768+	int32_t value;
5769+	int32_t minimum;
5770+	int32_t maximum;
5771+	int32_t fuzz;
5772+	int32_t flat;
5773+	int32_t resolution;
5774+	float	standardValue;
5775+};
5776+
5777 /**
5778  * @defgroup tablet_pad_modes Tablet pad modes
5779  *
5780@@ -702,6 +773,7 @@
5781 	 * in tablet mode.
5782 	 */
5783 	LIBINPUT_SWITCH_TABLET_MODE,
5784+	LIBINPUT_SWITCH_PRIVACY,
5785 };
5786
5787 /**
5788@@ -822,6 +894,16 @@
5789 	 */
5790 	LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS,
5791
5792+	LIBINPUT_EVENT_POINTER_TAP,
5793+	LIBINPUT_EVENT_POINTER_MOTION_TOUCHPAD,
5794+	LIBINPUT_EVENT_POINTER_BUTTON_TOUCHPAD,
5795+
5796+	LIBINPUT_EVENT_POINTER_SCROLL_FINGER_BEGIN,
5797+	LIBINPUT_EVENT_POINTER_SCROLL_FINGER_END,
5798+
5799+	LIBINPUT_EVENT_JOYSTICK_BUTTON = 450,
5800+	LIBINPUT_EVENT_JOYSTICK_AXIS,
5801+
5802 	LIBINPUT_EVENT_TOUCH_DOWN = 500,
5803 	LIBINPUT_EVENT_TOUCH_UP,
5804 	LIBINPUT_EVENT_TOUCH_MOTION,
5805@@ -832,6 +914,10 @@
5806 	 */
5807 	LIBINPUT_EVENT_TOUCH_FRAME,
5808
5809+	LIBINPUT_EVENT_TOUCHPAD_DOWN = 550,
5810+	LIBINPUT_EVENT_TOUCHPAD_UP,
5811+	LIBINPUT_EVENT_TOUCHPAD_MOTION,
5812+
5813 	/**
5814 	 * One or more axes have changed state on a device with the @ref
5815 	 * LIBINPUT_DEVICE_CAP_TABLET_TOOL capability. This event is only sent
5816@@ -984,6 +1070,8 @@
5817 	 * @since 1.7
5818 	 */
5819 	LIBINPUT_EVENT_SWITCH_TOGGLE = 900,
5820+
5821+	LIBINPUT_EVENT_MSDP = 1000,
5822 };
5823
5824 /**
5825@@ -1084,6 +1172,19 @@
5826 /**
5827  * @ingroup event
5828  *
5829+ * Return the touchpad event that is this input event. If the event type does
5830+ * not match the touchpad event types, this function returns NULL.
5831+ *
5832+ * The inverse of this function is libinput_event_touchpad_get_base_event().
5833+ *
5834+ * @return A touch event, or NULL for other events
5835+ */
5836+struct libinput_event_touch *
5837+libinput_event_get_touchpad_event(struct libinput_event *event);
5838+
5839+/**
5840+ * @ingroup event
5841+ *
5842  * Return the gesture event that is this input event. If the event type does
5843  * not match the gesture event types, this function returns NULL.
5844  *
5845@@ -1486,6 +1587,21 @@
5846 /**
5847  * @ingroup event_pointer
5848  *
5849+ * For the button of a @ref LIBINPUT_EVENT_POINTER_BUTTON event, return the
5850+ * total number of fingers on touchpad.
5851+ *
5852+ * @note It is an application bug to call this function for events other than
5853+ * @ref LIBINPUT_EVENT_POINTER_BUTTON. For other events, this function
5854+ * returns 0.
5855+ *
5856+ * @return The finger counts for touchpad button event
5857+ */
5858+uint32_t
5859+libinput_event_pointer_get_finger_count(
5860+	struct libinput_event_pointer *event);
5861+/**
5862+ * @ingroup event_pointer
5863+ *
5864  * Check if the event has a valid value for the given axis.
5865  *
5866  * If this function returns non-zero for an axis and
5867@@ -1870,6 +1986,120 @@
5868 				       uint32_t height);
5869
5870 /**
5871+ * @brief 获取触摸屏的工具类型区域属性
5872+ */
5873+int32_t
5874+libinput_event_touch_get_tool_type(struct libinput_event_touch *event);
5875+
5876+/**
5877+ * @ingroup event_touch
5878+ *
5879+ * Returns the absolute x coordinate of the center point of the current tool
5880+ * area, in mm from the upper left corner of the device. To get the
5881+ * corresponding output screen coordinates, use
5882+ * libinput_event_touch_get_tool_x_transformed().
5883+ *
5884+ * @param event The libinput touch event
5885+ * @return The current absolute x coordinate
5886+ */
5887+double
5888+libinput_event_touch_get_tool_x(struct libinput_event_touch *event);
5889+
5890+/**
5891+ * @ingroup event_touch
5892+ *
5893+ * Returns the absolute x coordinate of the center point of the current tool
5894+ * area, converted to screen coordinates.
5895+ *
5896+ * @param event The libinput touch event
5897+ * @param width The current output screen width
5898+ * @return The current absolute x coordinate transformed to a screen coordinate
5899+ */
5900+double
5901+libinput_event_touch_get_tool_x_transformed(struct libinput_event_touch *event,
5902+				       uint32_t width);
5903+
5904+/**
5905+ * @ingroup event_touch
5906+ *
5907+ * Returns the absolute y coordinate of the center point of the current tool
5908+ * area, in mm from the upper left corner of the device. To get the
5909+ * corresponding output screen coordinates, use
5910+ * libinput_event_touch_get_tool_y_transformed().
5911+ *
5912+ * @param event The libinput touch event
5913+ * @return The current absolute y coordinate
5914+ */
5915+double
5916+libinput_event_touch_get_tool_y(struct libinput_event_touch *event);
5917+
5918+/**
5919+ * @ingroup event_touch
5920+ *
5921+ * Returns the absolute y coordinate of the center point of the current tool
5922+ * area, converted to screen coordinates.
5923+ *
5924+ * @param event The libinput touch event
5925+ * @param height The current output screen height
5926+ * @return The current absolute y coordinate transformed to a screen coordinate
5927+ */
5928+double
5929+libinput_event_touch_get_tool_y_transformed(struct libinput_event_touch *event,
5930+				       uint32_t height);
5931+
5932+/**
5933+ * @ingroup event_touch
5934+ *
5935+ * Returns the width of the current tool area. To get the corresponding output
5936+ * screen width, use
5937+ * libinput_event_touch_get_tool_width_transformed().
5938+ *
5939+ * @param event The libinput touch event
5940+ * @return The current width
5941+ */
5942+double
5943+libinput_event_touch_get_tool_width(struct libinput_event_touch *event);
5944+
5945+/**
5946+ * @ingroup event_touch
5947+ *
5948+ * Returns the width of the current tool area, converted to screen width.
5949+ *
5950+ * @param event The libinput touch event
5951+ * @param width The current output screen width
5952+ * @return Convert current width to screen width
5953+ */
5954+double
5955+libinput_event_touch_get_tool_width_transformed(struct libinput_event_touch *event,
5956+				       uint32_t width);
5957+
5958+/**
5959+ * @ingroup event_touch
5960+ *
5961+ * Returns the height of the current tool area. To get the corresponding output
5962+ * screen height, use
5963+ * libinput_event_touch_get_tool_height_transformed().
5964+ *
5965+ * @param event The libinput touch event
5966+ * @return The current height
5967+ */
5968+double
5969+libinput_event_touch_get_tool_height(struct libinput_event_touch *event);
5970+
5971+/**
5972+ * @ingroup event_touch
5973+ *
5974+ * Returns the height of the current tool area, converted to screen height.
5975+ *
5976+ * @param event The libinput touch event
5977+ * @param height The current output screen height
5978+ * @return Convert current height to screen height
5979+ */
5980+double
5981+libinput_event_touch_get_tool_height_transformed(struct libinput_event_touch *event,
5982+				       uint32_t height);
5983+
5984+/**
5985  * @ingroup event_touch
5986  *
5987  * @return The generic libinput_event of this event
5988@@ -1878,6 +2108,228 @@
5989 libinput_event_touch_get_base_event(struct libinput_event_touch *event);
5990
5991 /**
5992+ * @defgroup event_touch Touchpad events
5993+ *
5994+ * Events from absolute touchpad devices.
5995+ */
5996+
5997+/**
5998+ * @ingroup event_touch
5999+ *
6000+ * @note Timestamps may not always increase. See the libinput documentation
6001+ * for more details.
6002+ *
6003+ * @return The event time for this event
6004+ */
6005+uint32_t
6006+libinput_event_touchpad_get_time(struct libinput_event_touch *event);
6007+
6008+/**
6009+ * @ingroup event_touch
6010+ *
6011+ * @note Timestamps may not always increase. See the libinput documentation
6012+ * for more details.
6013+ *
6014+ * @return The event time for this event in microseconds
6015+ */
6016+uint64_t
6017+libinput_event_touchpad_get_time_usec(struct libinput_event_touch *event);
6018+
6019+/**
6020+ * @ingroup event_touch
6021+ *
6022+ * Get the slot of this touchpad event. See the kernel's multitouch
6023+ * protocol B documentation for more information.
6024+ *
6025+ * If the touchpad event has no assigned slot, for example if it is from a
6026+ * single touchpad device, this function returns -1.
6027+ *
6028+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6029+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION,
6030+ * this function returns 0.
6031+ *
6032+ * @note It is an application bug to call this function for events of type
6033+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or
6034+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION.
6035+ *
6036+ * @return The slot of this touchpad event
6037+ */
6038+int32_t
6039+libinput_event_touchpad_get_slot(struct libinput_event_touch *event);
6040+
6041+/**
6042+ * @ingroup event_touch
6043+ *
6044+ * Get the seat slot of the touchpad event. A seat slot is a non-negative seat
6045+ * wide unique identifier of an active touchpad point.
6046+ *
6047+ * Events from single touchpad devices will be represented as one individual
6048+ * touchpad point per device.
6049+ *
6050+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6051+ * LIBINPUT_EVENT_TOUCHPAD_UP or @ref LIBINPUT_EVENT_TOUCHPAD_MOTION,
6052+ * this function returns 0.
6053+ *
6054+ * @note It is an application bug to call this function for events of type
6055+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref LIBINPUT_EVENT_TOUCHPAD_UP or
6056+ * @ref LIBINPUT_EVENT_TOUCHPAD_MOTION.
6057+ *
6058+ * @return The seat slot of the touchpad event
6059+ */
6060+int32_t
6061+libinput_event_touchpad_get_seat_slot(struct libinput_event_touch *event);
6062+
6063+/**
6064+ * @ingroup event_touch
6065+ *
6066+ * Return the current absolute x coordinate of the touchpad event, in mm from
6067+ * the top left corner of the device.
6068+ *
6069+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6070+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
6071+ *
6072+ * @note It is an application bug to call this function for events of type
6073+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref
6074+ * LIBINPUT_EVENT_TOUCHPAD_MOTION.
6075+ *
6076+ * @param event The libinput touchpad event
6077+ * @return The current absolute x coordinate
6078+ */
6079+double
6080+libinput_event_touchpad_get_x(struct libinput_event_touch *event);
6081+
6082+/**
6083+ * @ingroup event_touch
6084+ *
6085+ * Return the current absolute y coordinate of the touchpad event, in mm from
6086+ * the top left corner of the device.
6087+ *
6088+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6089+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
6090+ *
6091+ * @note It is an application bug to call this function for events of type
6092+ * other than @ref LIBINPUT_EVENT_TOUCHPAD_DOWN or @ref
6093+ * LIBINPUT_EVENT_TOUCHPAD_MOTION.
6094+ *
6095+ * @param event The libinput touchpad event
6096+ * @return The current absolute y coordinate
6097+ */
6098+double
6099+libinput_event_touchpad_get_y(struct libinput_event_touch *event);
6100+
6101+/**
6102+ * @ingroup event_touch
6103+ *
6104+ * Get the pressure of the touch pad
6105+ *
6106+ * @param event The libinput touch event
6107+ * @return Touchpad pressure value
6108+ *
6109+ */
6110+double
6111+libinput_event_touchpad_get_pressure(struct libinput_event_touch *event);
6112+
6113+/**
6114+ * @ingroup event_touch
6115+ *
6116+ * Gets the long axis of the touchpoint region of the touchpad
6117+ *
6118+ * @param event The libinput touch event
6119+ * @return The long axis value of the touchpoint area of the touchpad
6120+ */
6121+int32_t
6122+libinput_event_touchpad_get_touch_contact_long_axis(struct libinput_event_touch *event);
6123+
6124+/**
6125+ * @ingroup event_touch
6126+ *
6127+ * Gets the short axis of the touchpoint region of the touchpad
6128+ *
6129+ * @param event The libinput touch event
6130+ * @return The short axis value of the touchpoint area of the touchpad
6131+ */
6132+int32_t
6133+libinput_event_touchpad_get_touch_contact_short_axis(struct libinput_event_touch *event);
6134+
6135+/**
6136+ * @brief 获取触摸板的工具类型区域属性
6137+ */
6138+int32_t
6139+libinput_event_touchpad_get_tool_type(struct libinput_event_touch *event);
6140+
6141+/**
6142+ * @brief 获取触摸板工具类型按钮是否按下
6143+ */
6144+int32_t
6145+libinput_device_touchpad_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType);
6146+
6147+/**
6148+ * @ingroup event_touch
6149+ *
6150+ * @return The generic libinput_event of this event
6151+ */
6152+struct libinput_event *
6153+libinput_event_touchpad_get_base_event(struct libinput_event_touch *event);
6154+
6155+/**
6156+ * @ingroup event_touch
6157+ *
6158+ * Return the X coordinate of the center of the contact tool contour, in mm from
6159+ * the top left corner of the device.
6160+ *
6161+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6162+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
6163+ *
6164+ * @param event The libinput touchpad event
6165+ * @return The X coordinate of the center of the contact tool contour
6166+ */
6167+double
6168+libinput_event_touchpad_get_tool_x(struct libinput_event_touch *event);
6169+
6170+/**
6171+ * @ingroup event_touch
6172+ *
6173+ * Return the Y coordinate of the center of the contact tool contour, in mm from
6174+ * the top left corner of the device.
6175+ *
6176+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6177+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
6178+ *
6179+ * @param event The libinput touchpad event
6180+ * @return The Y coordinate of the center of the contact tool contour
6181+ */
6182+double
6183+libinput_event_touchpad_get_tool_y(struct libinput_event_touch *event);
6184+
6185+/**
6186+ * @ingroup event_touch
6187+ *
6188+ * Return the width of the current tool area.
6189+ *
6190+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6191+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
6192+ *
6193+ * @param event The libinput touchpad event
6194+ * @return The width of the current tool area
6195+ */
6196+double
6197+libinput_event_touchpad_get_tool_width(struct libinput_event_touch *event);
6198+
6199+/**
6200+ * @ingroup event_touch
6201+ *
6202+ * Return the height of the current tool area.
6203+ *
6204+ * For events not of type @ref LIBINPUT_EVENT_TOUCHPAD_DOWN, @ref
6205+ * LIBINPUT_EVENT_TOUCHPAD_MOTION, this function returns 0.
6206+ *
6207+ * @param event The libinput touchpad event
6208+ * @return The height of the current tool area
6209+ */
6210+double
6211+libinput_event_touchpad_get_tool_height(struct libinput_event_touch *event);
6212+
6213+/**
6214  * @defgroup event_gesture Gesture events
6215  *
6216  * Gesture events are generated when a gesture is recognized on a touchpad.
6217@@ -2090,6 +2542,49 @@
6218 libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event);
6219
6220 /**
6221+ * 获取gesture中手指的坐标信息, idx表示手指的索引
6222+ */
6223+int
6224+libinput_event_gesture_get_device_coords_x(struct libinput_event_gesture *event, uint32_t idx);
6225+int
6226+libinput_event_gesture_get_device_coords_y(struct libinput_event_gesture *event, uint32_t idx);
6227+/**
6228+ * 获取带slot的touches信息, 仅支持LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE
6229+ */
6230+struct sloted_coords_info *
6231+libinput_event_gesture_get_solt_touches(struct libinput_event_gesture *event);
6232+
6233+/**
6234+ * @brief Obtain the device values the EV_LED event type
6235+ *
6236+ * @param device  A current input device
6237+ * @return int Obtained is Supported
6238+ */
6239+int libinput_has_event_led_type(struct libinput_device *device);
6240+
6241+/**
6242+ * @brief Obtain the function key enablement status of a keyboard device
6243+ *
6244+ * @param device  A current input device
6245+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL,
6246+ * given code (see linux/input-event-codes.h).
6247+ * @return int Obtained state
6248+ */
6249+int libinput_get_funckey_state(struct libinput_device *device, unsigned int code);
6250+
6251+/**
6252+ * @brief Turn an LED on or off. Convenience function, if you need to modify multiple
6253+ * LEDs simultaneously, use libinput_set_led_state() instead.
6254+ *
6255+ * @param device  A current input device
6256+ * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL,
6257+ * given code (see linux/input-event-codes.h).
6258+ * @param state value Specifies whether to turn the LED on or off
6259+ * @return int 0 on success, or a negative errno on failure
6260+ */
6261+int libinput_set_led_state(struct libinput_device *device, unsigned int code, unsigned int state);
6262+
6263+/**
6264  * @defgroup event_tablet Tablet events
6265  *
6266  * Events that come from tools on tablet devices. For events from the pad,
6267@@ -2817,6 +3312,19 @@
6268 /**
6269  * @ingroup event_tablet
6270  *
6271+ * Get the stylus event type reported from evdev_tablet
6272+ *
6273+ * @param event The libinput tablet tool event
6274+ * @return Tool type for stylus events
6275+ *
6276+ * @since 1.2
6277+ */
6278+int32_t
6279+libinput_event_tablet_tool_get_tool_type(struct libinput_event_tablet_tool *event);
6280+
6281+/**
6282+ * @ingroup event_tablet
6283+ *
6284  * Return the high-level tool type for a tool object.
6285  *
6286  * The high level tool describes general interaction expected with the tool.
6287@@ -3663,6 +4171,56 @@
6288 int
6289 libinput_dispatch(struct libinput *libinput);
6290
6291+/****************************************************************************
6292+* @brief : brief
6293+* @author : fms
6294+* @date : 2021/3/8 20:55
6295+* @version : ver 1.0
6296+* @inparam :libinput  event
6297+* @outparam :
6298+*****************************************************************************/
6299+void
6300+libinput_post_handle_event(struct libinput* libinput,
6301+	struct libinput_event* event);
6302+
6303+/****************************************************************************
6304+* @brief : get joystick button event
6305+* @author : fms
6306+* @date : 2021/3/12 10:56
6307+* @version : ver 1.0
6308+* @inparam :
6309+* @outparam :
6310+*****************************************************************************/
6311+struct libinput_event_joystick_button*
6312+libinput_event_get_joystick_button_event(struct libinput_event* event);
6313+
6314+/****************************************************************************
6315+* @brief : get joystick axis event
6316+* @author : fms
6317+* @date : 2021/3/12 10:56
6318+* @version : ver 1.0
6319+* @inparam :
6320+* @outparam :
6321+*****************************************************************************/
6322+struct libinput_event_joystick_axis*
6323+    libinput_event_get_joystick_axis_event(struct libinput_event* event);
6324+/**
6325+ * @brief 获取轴事件的时间
6326+ */
6327+uint64_t
6328+libinput_event_get_joystick_axis_time(struct libinput_event_joystick_axis *event);
6329+
6330+/**
6331+ * @brief 获取joystick指定轴的数据是否变化
6332+*/
6333+int32_t libinput_event_get_joystick_axis_value_is_changed(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis);
6334+
6335+/**
6336+ * @brief 获取joystick指定轴的abs信息
6337+*/
6338+struct libinput_event_joystick_axis_abs_info *
6339+libinput_event_get_joystick_axis_abs_info(struct libinput_event_joystick_axis *event, enum libinput_joystick_axis_source axis);
6340+
6341 /**
6342  * @ingroup base
6343  *
6344@@ -4133,6 +4691,42 @@
6345 const char *
6346 libinput_device_get_name(struct libinput_device *device);
6347
6348+/**  @brief   获取设备类型*/
6349+enum evdev_device_udev_tags
6350+libinput_device_get_tags(struct libinput_device* device);
6351+
6352+/**  @brief   设备按键能力查询*/
6353+int32_t
6354+libinput_device_has_key(struct libinput_device* device, int32_t keyCode);
6355+
6356+/**  @brief   获取设备特定轴的最小值*/
6357+int32_t
6358+libinput_device_get_axis_min(struct libinput_device* device, int32_t code);
6359+
6360+/**  @brief   获取设备特定轴的最大值*/
6361+int32_t
6362+libinput_device_get_axis_max(struct libinput_device* device, int32_t code);
6363+
6364+/**  @brief   获取设备特定轴的fuzz值*/
6365+int32_t
6366+libinput_device_get_axis_fuzz(struct libinput_device* device, int32_t code);
6367+
6368+/**  @brief   获取设备特定轴的flat值*/
6369+int32_t
6370+libinput_device_get_axis_flat(struct libinput_device* device, int32_t code);
6371+
6372+/**  @brief   获取设备特定轴的resolution值*/
6373+int32_t
6374+libinput_device_get_axis_resolution(struct libinput_device* device, int32_t code);
6375+
6376+/**  @brief   获取设备的bustype值*/
6377+unsigned int
6378+libinput_device_get_id_bustype(struct libinput_device* device);
6379+
6380+/**  @brief   获取设备的version值*/
6381+unsigned int
6382+libinput_device_get_id_version(struct libinput_device* device);
6383+
6384 /**
6385  * @ingroup device
6386  *
6387@@ -4343,6 +4937,12 @@
6388 libinput_device_touch_get_touch_count(struct libinput_device *device);
6389
6390 /**
6391+ * @brief 获取触摸屏工具类型按钮是否按下
6392+ */
6393+int
6394+libinput_device_touch_btn_tool_type_down(struct libinput_device *device, int32_t btnToolType);
6395+
6396+/**
6397  * @ingroup device
6398  *
6399  * Check if a @ref LIBINPUT_DEVICE_CAP_SWITCH device has a switch of the
6400@@ -5722,6 +6322,9 @@
6401 enum libinput_config_click_method
6402 libinput_device_config_click_get_default_method(struct libinput_device *device);
6403
6404+uint64_t
6405+libinput_event_get_sensortime(struct libinput_event *event);
6406+
6407 /**
6408  * @ingroup config
6409  */
6410@@ -6398,7 +7001,108 @@
6411 unsigned int
6412 libinput_device_config_rotation_get_default_angle(struct libinput_device *device);
6413
6414+/**
6415+ * @ingroup event
6416+ *
6417+ * Get the struct libinput_event_joystick_button from the event.
6418+ *
6419+ * @param event The libinput event
6420+ * @return The libinput_event_joystick_button for this event.
6421+ */
6422+struct libinput_event_joystick_button*
6423+libinput_event_get_joystick_pointer_button_event(struct libinput_event* event);
6424+
6425+/**
6426+ * @ingroup event
6427+ *
6428+ * Get the time from the event.
6429+ *
6430+ * @param event The libinput_event_joystick_button
6431+ * @return The time for this event.
6432+ */
6433+uint64_t libinput_event_joystick_button_time(struct libinput_event_joystick_button* event);
6434+
6435+/**
6436+ * @ingroup event
6437+ *
6438+ * Get the key value from the event.
6439+ *
6440+ * @param event The libinput_event_joystick_button
6441+ * @return The key value for this event.
6442+ */
6443+uint32_t libinput_event_joystick_button_get_key(struct libinput_event_joystick_button* event);
6444+
6445+/**
6446+ * @ingroup event
6447+ *
6448+ * Get the seat key count from the event.
6449+ *
6450+ * @param event The libinput_event_joystick_button
6451+ * @return The seat key count for this event.
6452+ */
6453+uint32_t libinput_event_joystick_button_get_seat_key_count(struct libinput_event_joystick_button* event);
6454+
6455+/**
6456+ * @ingroup event
6457+ *
6458+ * Get the value count from the event.
6459+ *
6460+ * @param event The libinput_event_joystick_button
6461+ * @return The value for this event.
6462+ */
6463+int libinput_event_joystick_button_get_value(struct libinput_event_joystick_button* event);
6464+
6465+/**
6466+ * @ingroup config
6467+ *
6468+ * Get the pressure of the touch screen
6469+ *
6470+ * @param Carried libinput event
6471+ * @return Pressure value of touch screen
6472+ *
6473+ * @since 1.4
6474+ */
6475+double
6476+libinput_event_touch_get_pressure(struct libinput_event_touch* event);
6477+
6478+int32_t
6479+libinput_event_get_hand_feature(struct libinput_event *event);
6480+
6481+int32_t
6482+libinput_event_touch_get_blob_id(struct libinput_event_touch* event);
6483+
6484+/**
6485+ * @ingroup event_touch
6486+ *
6487+ * Gets the long axis of the touch point region of the touch screen
6488+ *
6489+ * @param event The libinput touch event
6490+ * @return Long axis value of touch point region
6491+ */
6492+int32_t
6493+libinput_event_get_touch_contact_long_axis(struct libinput_event_touch *event);
6494+
6495+/**
6496+ * @ingroup event_touch
6497+ *
6498+ * Gets the short axis of the touch point region of the touch screen
6499+ *
6500+ * @param event The libinput touch event
6501+ * @return Short axis value of touch point region
6502+ */
6503+int32_t
6504+libinput_event_get_touch_contact_short_axis(struct libinput_event_touch *event);
6505+
6506+const char*
6507+libinput_device_get_phys(struct libinput_device* device);
6508+
6509+const char*
6510+libinput_device_get_uniq(struct libinput_device* device);
6511+
6512+enum libinput_button_state
6513+libinput_event_joystick_button_get_key_state(struct libinput_event_joystick_button* event);
6514 #ifdef __cplusplus
6515 }
6516 #endif
6517 #endif /* LIBINPUT_H */
6518+
6519diff -Naur old/src/libinput-private.h new/src/libinput-private.h
6520--- old/src/libinput-private.h	2024-01-01 00:00:00.000000000 +0800
6521+++ new/src/libinput-private.h	2024-01-01 00:00:00.000000000 +0800
6522@@ -43,12 +43,24 @@
6523 #include "libinput-version.h"
6524
6525 struct libinput_source;
6526+struct privacy_switch;
6527+
6528+/* The extra data of mt_slot struction */
6529+struct extra_data {
6530+	int32_t blob_id;
6531+};
6532
6533 /* A coordinate pair in device coordinates */
6534 struct device_coords {
6535 	int x, y;
6536 };
6537
6538+/* Size of touch point region (major and minor axes of ellipse) */
6539+struct touch_axis {
6540+    int32_t major;
6541+    int32_t minor;
6542+};
6543+
6544 /*
6545  * A coordinate pair in device coordinates, capable of holding non discrete
6546  * values, this is necessary e.g. when device coordinates get averaged.
6547@@ -424,7 +436,8 @@
6548 	LIBINPUT_TABLET_TOOL_AXIS_SLIDER = 8,
6549 	LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL = 9,
6550 	LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR = 10,
6551-	LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR = 11,
6552+	LIBINPUT_TABLET_TOOL_AXIS_TYPE = 11,
6553+	LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR = 12,
6554 };
6555
6556 #define LIBINPUT_TABLET_TOOL_AXIS_MAX LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR
6557@@ -463,7 +476,7 @@
6558 		struct threshold threshold; /* in device coordinates */
6559 		int offset; /* in device coordinates */
6560 		bool has_offset;
6561-
6562+		int32_t mt_tool_type;
6563 		enum pressure_heuristic_state heuristic_state;
6564 	} pressure;
6565 };
6566@@ -498,6 +511,20 @@
6567 	void *notify_func_data;
6568 };
6569
6570+struct joystick_axis_abs_infos {
6571+	struct libinput_event_joystick_axis_abs_info abs_throttle;
6572+	struct libinput_event_joystick_axis_abs_info abs_hat0x;
6573+	struct libinput_event_joystick_axis_abs_info abs_hat0y;
6574+	struct libinput_event_joystick_axis_abs_info abs_x;
6575+	struct libinput_event_joystick_axis_abs_info abs_y;
6576+	struct libinput_event_joystick_axis_abs_info abs_z;
6577+	struct libinput_event_joystick_axis_abs_info abs_rx;
6578+	struct libinput_event_joystick_axis_abs_info abs_ry;
6579+	struct libinput_event_joystick_axis_abs_info abs_rz;
6580+	struct libinput_event_joystick_axis_abs_info abs_gas;
6581+	struct libinput_event_joystick_axis_abs_info abs_brake;
6582+};
6583+
6584 typedef void (*libinput_source_dispatch_t)(void *data);
6585
6586 #define log_debug(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
6587@@ -628,6 +655,12 @@
6588 		      const struct device_float_coords *raw);
6589
6590 void
6591+touchpad_pointer_notify_motion(struct libinput_device *device,
6592+		      uint64_t time,
6593+		      const struct normalized_coords *delta,
6594+		      const struct device_float_coords *raw);
6595+
6596+void
6597 pointer_notify_motion_absolute(struct libinput_device *device,
6598 			       uint64_t time,
6599 			       const struct device_coords *point);
6600@@ -639,6 +672,18 @@
6601 		      enum libinput_button_state state);
6602
6603 void
6604+pointer_notify_button_touchpad(struct libinput_device *device,
6605+		      uint64_t time,
6606+		      int32_t button,
6607+		      enum libinput_button_state state);
6608+
6609+void
6610+pointer_notify_tap(struct libinput_device *device,
6611+		      uint64_t time,
6612+		      int32_t button,
6613+		      enum libinput_button_state state);
6614+
6615+void
6616 pointer_notify_axis_finger(struct libinput_device *device,
6617 			   uint64_t time,
6618 			   uint32_t axes,
6619@@ -664,24 +709,39 @@
6620 			  const struct wheel_v120 *v120);
6621
6622 void
6623+touch_notify_msdp(struct libinput_device *device,
6624+			  uint64_t time);
6625+
6626+void
6627 touch_notify_touch_down(struct libinput_device *device,
6628 			uint64_t time,
6629 			int32_t slot,
6630 			int32_t seat_slot,
6631-			const struct device_coords *point);
6632+			int32_t pressure,
6633+			const struct extra_data *extraData,
6634+            const struct touch_axis *axis,
6635+			const struct device_coords *point,
6636+			int32_t tool_type,
6637+			const struct device_coord_rect *tool_rect);
6638
6639 void
6640 touch_notify_touch_motion(struct libinput_device *device,
6641 			  uint64_t time,
6642 			  int32_t slot,
6643 			  int32_t seat_slot,
6644-			  const struct device_coords *point);
6645+			  int32_t pressure,
6646+			  const struct extra_data *extraData,
6647+              const struct touch_axis *axis,
6648+			  const struct device_coords *point,
6649+			  int32_t tool_type,
6650+			  const struct device_coord_rect *tool_rect);
6651
6652 void
6653 touch_notify_touch_up(struct libinput_device *device,
6654 		      uint64_t time,
6655 		      int32_t slot,
6656-		      int32_t seat_slot);
6657+		      int32_t seat_slot,
6658+		      int32_t tool_type);
6659
6660 void
6661 touch_notify_touch_cancel(struct libinput_device *device,
6662@@ -694,12 +754,53 @@
6663 		   uint64_t time);
6664
6665 void
6666+touchpad_notify_touch_down(struct libinput_device *device,
6667+			uint64_t time,
6668+			int32_t slot,
6669+			int32_t seat_slot,
6670+			int32_t pressure,
6671+			int32_t tool_type,
6672+			struct touch_axis axis,
6673+			const struct device_coords *point,
6674+			const struct device_coord_rect *tool_rect);
6675+
6676+void
6677+touchpad_notify_touch_motion(struct libinput_device *device,
6678+			  uint64_t time,
6679+			  int32_t slot,
6680+			  int32_t seat_slot,
6681+			  int32_t pressure,
6682+			  int32_t tool_type,
6683+			  struct touch_axis axis,
6684+			  const struct device_coords *point,
6685+			  const struct device_coord_rect *tool_rect);
6686+
6687+void
6688+touchpad_notify_touch_up(struct libinput_device *device,
6689+		      uint64_t time,
6690+		      int32_t slot,
6691+		      int32_t seat_slot,
6692+		      int32_t tool_type,
6693+			  struct touch_axis axis);
6694+
6695+void
6696 gesture_notify_swipe(struct libinput_device *device,
6697 		     uint64_t time,
6698 		     enum libinput_event_type type,
6699 		     int finger_count,
6700 		     const struct normalized_coords *delta,
6701-		     const struct normalized_coords *unaccel);
6702+		     const struct normalized_coords *unaccel,
6703+		     const struct sloted_coords_info *raw_touches);
6704+
6705+void
6706+gesture_notify_swipe_private(struct libinput_device *device,
6707+		     uint64_t time,
6708+		     enum libinput_event_type type,
6709+		     int finger_count,
6710+		     const struct normalized_coords *delta,
6711+		     const struct normalized_coords *unaccel,
6712+			 struct device_coords *coords,
6713+			 int coordsLen);
6714
6715 void
6716 gesture_notify_swipe_end(struct libinput_device *device,
6717@@ -725,6 +826,13 @@
6718 			 bool cancelled);
6719
6720 void
6721+gesture_notify_axis_finger(struct libinput_device *device,
6722+			  uint64_t time,
6723+			  enum libinput_event_type type,
6724+			  uint32_t axes,
6725+			  const struct normalized_coords *delta);
6726+
6727+void
6728 gesture_notify_hold(struct libinput_device *device,
6729 		    uint64_t time,
6730 		    int finger_count);
6731@@ -799,6 +907,17 @@
6732 		     enum libinput_switch sw,
6733 		     enum libinput_switch_state state);
6734
6735+void
6736+joysticks_notify_axis(struct libinput_device *device,
6737+			uint64_t time,
6738+			uint32_t axes,
6739+			const struct joystick_axis_abs_infos *axis_abs);
6740+
6741+void
6742+privacy_switch_notify_event(struct libinput_device *device,
6743+			uint64_t time,
6744+			struct privacy_switch* ev_switch);
6745+
6746 static inline uint64_t
6747 libinput_now(struct libinput *libinput)
6748 {
6749diff -Naur old/src/libinput-util.c new/src/libinput-util.c
6750--- old/src/libinput-util.c	1970-01-01 08:00:00.000000000 +0800
6751+++ new/src/libinput-util.c	2024-01-01 00:00:00.000000000 +0800
6752@@ -0,0 +1,102 @@
6753+/*
6754+ * Copyright © 2008-2011 Kristian Høgsberg
6755+ * Copyright © 2011 Intel Corporation
6756+ * Copyright © 2013-2015 Red Hat, Inc.
6757+ *
6758+ * Permission is hereby granted, free of charge, to any person obtaining a
6759+ * copy of this software and associated documentation files (the "Software"),
6760+ * to deal in the Software without restriction, including without limitation
6761+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
6762+ * and/or sell copies of the Software, and to permit persons to whom the
6763+ * Software is furnished to do so, subject to the following conditions:
6764+ *
6765+ * The above copyright notice and this permission notice (including the next
6766+ * paragraph) shall be included in all copies or substantial portions of the
6767+ * Software.
6768+ *
6769+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6770+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6771+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
6772+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6773+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6774+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
6775+ * DEALINGS IN THE SOFTWARE.
6776+ */
6777+
6778+/*
6779+ * This list data structure is verbatim copy from wayland-util.h from the
6780+ * Wayland project; except that wl_ prefix has been removed.
6781+ */
6782+
6783+#include "libinput-util.h"
6784+
6785+#ifdef HAVE_LIBINPUT_LOG_ENABLE
6786+
6787+static FILE* p_log_fp = NULL;
6788+
6789+FILE *libinput_get_log_fp()
6790+{
6791+    if (p_log_fp == NULL) {
6792+        const char *pLogDir = getenv("LIBINPUT_LOG_DIR");
6793+        if (pLogDir == NULL) {
6794+            pLogDir = (char *)_LIBINPUT_LOG_DIR;
6795+        }
6796+
6797+        const int r = mkdir(pLogDir, 0755);
6798+        if (r < 0 && errno != EEXIST) {
6799+            const int saved_errno = errno;
6800+            printf("could not create %s, errno: %d\n", pLogDir, saved_errno);
6801+            return NULL;
6802+        }
6803+
6804+        const char *p_log_path = getenv("LIBINPUT_LOG_PATH");
6805+        if (p_log_path == NULL) {
6806+            p_log_path = (char *)_LIBINPUT_LOG_PATH;
6807+        }
6808+        p_log_fp = fopen(p_log_path, "w+");
6809+    }
6810+
6811+    return p_log_fp;
6812+}
6813+
6814+void libinput_log_printf(const char* fmt, ...)
6815+{
6816+    p_log_fp = libinput_get_log_fp();
6817+#ifdef HAVE_LIBINPUT_LOG_CONSOLE_ENABLE
6818+    char buf[1024] = {0};
6819+
6820+    va_list args;
6821+    va_start(args, fmt);
6822+    vsprintf(buf, fmt, args);
6823+    va_end(args);
6824+    buf[1024 - 1] = '\0';
6825+
6826+    printf("%s\n", buf);
6827+
6828+    if (p_log_fp != NULL) {
6829+        fputs(buf, p_log_fp);
6830+        fflush(p_log_fp);
6831+    }
6832+#else
6833+    if (p_log_fp != NULL) {
6834+        va_list args;
6835+        va_start(args, fmt);
6836+        vfprintf(p_log_fp, fmt, args);
6837+        va_end(args);
6838+        fflush(p_log_fp);
6839+    }
6840+#endif
6841+}
6842+
6843+uint64_t getMicrotime()
6844+{
6845+    struct timeval currentTime;
6846+    gettimeofday(&currentTime, NULL);
6847+    return currentTime.tv_sec * 1000000 + currentTime.tv_usec;
6848+}
6849+
6850+uint64_t getTranTime(struct input_event *event)
6851+{
6852+    return event->input_event_sec * 1000000 + event->input_event_usec;
6853+}
6854+#endif
6855diff -Naur old/src/libinput-util.h new/src/libinput-util.h
6856--- old/src/libinput-util.h	2024-01-01 00:00:00.000000000 +0800
6857+++ new/src/libinput-util.h	2024-01-01 00:00:00.000000000 +0800
6858@@ -27,9 +27,9 @@
6859
6860 #include "config.h"
6861
6862-#ifdef NDEBUG
6863-#warning "libinput relies on assert(). #defining NDEBUG is not recommended"
6864-#endif
6865+// #ifdef NDEBUG
6866+// #warning "libinput relies on assert(). #defining NDEBUG is not recommended"
6867+// #endif
6868
6869 #include "libinput.h"
6870
6871@@ -56,6 +56,15 @@
6872 #define DEFAULT_MOUSE_DPI 1000
6873 #define DEFAULT_TRACKPOINT_SENSITIVITY 128
6874
6875+
6876+#ifdef HAVE_LIBINPUT_LOG_ENABLE
6877+void libinput_log_printf(const char* fmt, ...);
6878+uint64_t getMicrotime();
6879+uint64_t getTranTime(struct input_event *event);
6880+#else
6881+#define libinput_log_printf(fmt, ...)
6882+#endif
6883+
6884 #define trace(...) \
6885 	do { \
6886 	printf("%s() - \033[0;31m", __func__); \
6887diff -Naur old/src/udev-seat.c new/src/udev-seat.c
6888--- old/src/udev-seat.c	2024-01-01 00:00:00.000000000 +0800
6889+++ new/src/udev-seat.c	2024-01-01 00:00:00.000000000 +0800
6890@@ -190,6 +190,7 @@
6891
6892 		/* Skip unconfigured device. udev will send an event
6893 		 * when device is fully configured  */
6894+/*
6895 		if (!udev_device_get_is_initialized(device)) {
6896 			log_debug(&input->base,
6897 				  "%-7s - skip unconfigured input device '%s'\n",
6898@@ -198,6 +199,13 @@
6899 			udev_device_unref(device);
6900 			continue;
6901 		}
6902+*/
6903+		if (!udev_device_get_is_initialized(device)) {
6904+			log_info(&input->base,
6905+				  "%-7s - unconfigured input device '%s'\n",
6906+				  sysname,
6907+				  udev_device_get_devnode(device));
6908+		}
6909
6910 		if (device_added(device, input, NULL) < 0) {
6911 			udev_device_unref(device);
6912diff -Naur old/src/util-strings.h new/src/util-strings.h
6913--- old/src/util-strings.h	2024-01-01 00:00:00.000000000 +0800
6914+++ new/src/util-strings.h	2024-07-11 10:45:06.197570145 +0800
6915@@ -308,7 +308,7 @@
6916 	if (!strv)
6917 		return result;
6918
6919-	double *numv = zalloc(sizeof(double) * nelem);
6920+	double *numv = (double *)zalloc(sizeof(double) * nelem);
6921 	for (size_t idx = 0; idx < nelem; idx++) {
6922 		double val;
6923 		if (!safe_atod(strv[idx], &val))
6924@@ -355,7 +355,7 @@
6925 	if (!pairs || npairs == 0)
6926 		goto error;
6927
6928-	result = zalloc(npairs * sizeof *result);
6929+	result = (struct key_value_double *)zalloc(npairs * sizeof *result);
6930
6931 	for (size_t idx = 0; idx < npairs; idx++) {
6932 		char *pair = pairs[idx];
6933@@ -468,7 +468,7 @@
6934 		return strdup(str);
6935
6936 	size_t slen = min(strlen(str), 512);
6937-	char *sanitized = zalloc(2 * slen + 1);
6938+	char *sanitized = (char *)zalloc(2 * slen + 1);
6939 	const char *src = str;
6940 	char *dst = sanitized;
6941
6942diff -Naur old/src/util-time.h new/src/util-time.h
6943--- old/src/util-time.h	2024-01-01 00:00:00.000000000 +0800
6944+++ new/src/util-time.h	2024-01-01 00:00:00.000000000 +0800
6945@@ -109,7 +109,8 @@
6946 static inline struct human_time
6947 to_human_time(uint64_t us)
6948 {
6949-	struct human_time t;
6950+	uint64_t l = 0;
6951+	struct human_time t = {0, NULL};
6952 	struct c {
6953 		const char *unit;
6954 		unsigned int change_from_previous;
6955@@ -120,7 +121,7 @@
6956 		{"s", 1000, 120},
6957 		{"min", 60, 120},
6958 		{"h", 60, 48},
6959-		{"d", 24, ~0},
6960+		{"d", 24, ~l},
6961 	};
6962 	uint64_t value = us;
6963
6964@@ -132,6 +133,6 @@
6965 			return t;
6966 		}
6967 	}
6968-
6969-	assert(!"We should never get here");
6970+return t;
6971+	//assert(1);
6972 }
6973diff -Naur old/tools/libinput-debug-events.c new/tools/libinput-debug-events.c
6974--- old/tools/libinput-debug-events.c	2024-01-01 00:00:00.000000000 +0800
6975+++ new/tools/libinput-debug-events.c	2024-01-01 00:00:00.000000000 +0800
6976@@ -110,6 +110,15 @@
6977 	case LIBINPUT_EVENT_TOUCH_FRAME:
6978 		type = "TOUCH_FRAME";
6979 		break;
6980+	case LIBINPUT_EVENT_TOUCHPAD_DOWN:
6981+		type = "TOUCHPAD_DOWN";
6982+		break;
6983+	case LIBINPUT_EVENT_TOUCHPAD_MOTION:
6984+		type = "TOUCHPAD_MOTION";
6985+		break;
6986+	case LIBINPUT_EVENT_TOUCHPAD_UP:
6987+		type = "TOUCHPAD_UP";
6988+		break;
6989 	case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
6990 		type = "GESTURE_SWIPE_BEGIN";
6991 		break;
6992@@ -161,6 +170,8 @@
6993 	case LIBINPUT_EVENT_SWITCH_TOGGLE:
6994 		type = "SWITCH_TOGGLE";
6995 		break;
6996+	default:
6997+		break;
6998 	}
6999
7000 	prefix = (last_device != dev) ? '-' : ' ';
7001@@ -297,6 +308,10 @@
7002 					   LIBINPUT_DEVICE_CAP_SWITCH))
7003 		printq("S");
7004
7005+    if (libinput_device_has_capability(dev,
7006+        LIBINPUT_DEVICE_CAP_JOYSTICK))
7007+        printq("JOYSTICK");
7008+
7009 	if (libinput_device_get_size(dev, &w, &h) == 0)
7010 		printq("  size %.0fx%.0fmm", w, h);
7011
7012@@ -547,6 +562,15 @@
7013 }
7014
7015 static void
7016+print_touchpad_event_without_coords(struct libinput_event *ev)
7017+{
7018+	struct libinput_event_touch *t = libinput_event_get_touchpad_event(ev);
7019+
7020+	print_event_time(libinput_event_touchpad_get_time(t));
7021+	printq("\n");
7022+}
7023+
7024+static void
7025 print_proximity_event(struct libinput_event *ev)
7026 {
7027 	struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
7028@@ -673,6 +697,21 @@
7029 }
7030
7031 static void
7032+print_touchpad_event_with_coords(struct libinput_event *ev)
7033+{
7034+	struct libinput_event_touch *t = libinput_event_get_touchpad_event(ev);
7035+	double xmm = libinput_event_touchpad_get_x(t);
7036+	double ymm = libinput_event_touchpad_get_y(t);
7037+
7038+	print_event_time(libinput_event_touchpad_get_time(t));
7039+
7040+	printq("%d (%d) %5.2f/%5.2fmm\n",
7041+	       libinput_event_touchpad_get_slot(t),
7042+	       libinput_event_touchpad_get_seat_slot(t),
7043+	       xmm, ymm);
7044+}
7045+
7046+static void
7047 print_gesture_event_without_coords(struct libinput_event *ev)
7048 {
7049 	struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev);
7050@@ -895,6 +934,15 @@
7051 		case LIBINPUT_EVENT_TOUCH_FRAME:
7052 			print_touch_event(ev);
7053 			break;
7054+		case LIBINPUT_EVENT_TOUCHPAD_DOWN:
7055+			print_touchpad_event_with_coords(ev);
7056+			break;
7057+		case LIBINPUT_EVENT_TOUCHPAD_MOTION:
7058+			print_touchpad_event_with_coords(ev);
7059+			break;
7060+		case LIBINPUT_EVENT_TOUCHPAD_UP:
7061+			print_touchpad_event_without_coords(ev);
7062+			break;
7063 		case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
7064 			print_gesture_event_without_coords(ev);
7065 			break;
7066@@ -946,6 +994,8 @@
7067 		case LIBINPUT_EVENT_SWITCH_TOGGLE:
7068 			print_switch_event(ev);
7069 			break;
7070+		default:
7071+			break;
7072 		}
7073
7074 		libinput_event_destroy(ev);
7075diff -Naur old/tools/libinput-record.c new/tools/libinput-record.c
7076--- old/tools/libinput-record.c	2024-01-01 00:00:00.000000000 +0800
7077+++ new/tools/libinput-record.c	2024-01-01 00:00:00.000000000 +0800
7078@@ -53,6 +53,7 @@
7079 #include "util-time.h"
7080 #include "util-input-event.h"
7081 #include "util-macros.h"
7082+#include "hm_missing.h"
7083
7084 static const int FILE_VERSION_NUMBER = 1;
7085
7086diff -Naur old/udev/libinput-device-group.c new/udev/libinput-device-group.c
7087--- old/udev/libinput-device-group.c	2024-01-01 00:00:00.000000000 +0800
7088+++ new/udev/libinput-device-group.c	2024-01-01 00:00:00.000000000 +0800
7089@@ -137,7 +137,7 @@
7090 				*product_id = pid;
7091 				best_dist = dist;
7092
7093-				free(*phys_attr);
7094+				free((char*)*phys_attr);
7095 				*phys_attr = safe_strdup(phys);
7096 			}
7097 		}
7098