@@ -75,6 +75,8 @@ def close(self, exit: bool) -> bool:
7575 def consume (self , events : Sequence [Event ]):
7676 if not self .dev :
7777 return
78+
79+ wrote = False
7880 for ev in events :
7981 match ev ["type" ]:
8082 case "axis" :
@@ -90,6 +92,7 @@ def consume(self, events: Sequence[Event]):
9092 if ax .bounds :
9193 val = min (max (val , ax .bounds [0 ]), ax .bounds [1 ])
9294 self .dev .write (B ("EV_ABS" ), ax .id , val )
95+ wrote = True
9396
9497 if ev ["code" ] == "touchpad_x" :
9598 self .dev .write (B ("EV_ABS" ), B ("ABS_MT_POSITION_X" ), val )
@@ -108,6 +111,7 @@ def consume(self, events: Sequence[Event]):
108111 self .ofs = ts
109112 ts -= self .ofs
110113 self .dev .write (B ("EV_MSC" ), B ("MSC_TIMESTAMP" ), ts )
114+ wrote = True
111115 case "button" :
112116 if ev ["code" ] in self .btn_map :
113117 if ev ["code" ] == "touchpad_touch" :
@@ -129,12 +133,13 @@ def consume(self, events: Sequence[Event]):
129133 self .btn_map [ev ["code" ]],
130134 1 if ev ["value" ] else 0 ,
131135 )
136+ wrote = True
132137
133138 case "configuration" :
134139 if ev ["code" ] == "touchpad_aspect_ratio" :
135140 self .touchpad_aspect = float (ev ["value" ])
136141
137- if self .output_timestamps :
142+ if wrote and self .output_timestamps :
138143 # We have timestamps with ns accuracy.
139144 # Evdev expects us accuracy
140145 ts = time .perf_counter_ns () // 1000
@@ -144,7 +149,8 @@ def consume(self, events: Sequence[Event]):
144149 ts -= self .ofs
145150 self .dev .write (B ("EV_MSC" ), B ("MSC_TIMESTAMP" ), ts )
146151
147- self .dev .syn ()
152+ if wrote :
153+ self .dev .syn ()
148154
149155 def produce (self , fds : Sequence [int ]) -> Sequence [Event ]:
150156 if not self .fd or not self .fd in fds or not self .dev :
0 commit comments