tools: per-slot-delta: print the BTN_TOUCH etc. bits in-line
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 27 Mar 2020 00:30:38 +0000 (10:30 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Sat, 11 Apr 2020 03:38:48 +0000 (13:38 +1000)
New output example:

 9.408899    +5ms DBL: ↑↗    1/  -9 | →→    0/   0 |

where DBL stands for BTN_DOUBLE.

This also widens the relative time by one so we don't lose formatting for >1s
delta time.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-analyze-per-slot-delta.man
tools/libinput-analyze-per-slot-delta.py

index 567ba57..11c6686 100644 (file)
@@ -34,11 +34,11 @@ flag.
 .PP
 .nf
 .sf
- 0.000000   +0ms:     ++++++     |  ************* |
- 0.021900  +21ms: →↘ +1.10/+0.14 |  ************* |
- 0.033468  +11ms: →↘ +1.15/+0.19 |  ************* |
- 0.043856  +10ms: →↘ +1.76/+0.22 |  ************* |
- 0.053237   +9ms: →↘ +2.20/+0.19 |  ************* |
+ 0.000000   +0ms TOU:     ++++++     |  ************* |
+ 0.021900  +21ms TOU: →↘ +1.10/+0.14 |  ************* |
+ 0.033468  +11ms TOU: →↘ +1.15/+0.19 |  ************* |
+ 0.043856  +10ms TOU: →↘ +1.76/+0.22 |  ************* |
+ 0.053237   +9ms TOU: →↘ +2.20/+0.19 |  ************* |
 .fi
 .in
 .PP
@@ -48,8 +48,18 @@ indicates a finger has been put down,
 .B ------
 indicates the finger has lifted.
 The left-most column is the absolute timestamp in seconds.microseconds
-followed by the relative time of the event to the previous event. The arrows
-indicate the approximate direction on a 16-point compass.
+followed by the relative time of the event to the previous event.
+.PP
+The word
+.B TOU
+in this example represents
+BTN_TOUCH, similar abbreviations exist for
+BTN_TOOL_DOUBLETAP, BTN_TOOL_TRIPLETAP, BTN_TOOL_QUADTAP, and
+BTN_TOOL_QUINTTAP.
+.PP
+The arrows
+indicate the approximate direction on a 16-point compass, in this example
+EastSouthEast.
 .PP
 Each multitouch slot supported by the hardware has one column, where the
 column shows asterisk
index 0df3a9b..3c8de82 100755 (executable)
@@ -123,6 +123,13 @@ def main(argv):
 
     slot = 0
     last_time = None
+    tool_bits = {
+        libevdev.EV_KEY.BTN_TOUCH: 0,
+        libevdev.EV_KEY.BTN_TOOL_DOUBLETAP: 0,
+        libevdev.EV_KEY.BTN_TOOL_TRIPLETAP: 0,
+        libevdev.EV_KEY.BTN_TOOL_QUADTAP: 0,
+        libevdev.EV_KEY.BTN_TOOL_QUINTTAP: 0,
+    }
 
     for event in device['events']:
         for evdev in event['evdev']:
@@ -130,6 +137,9 @@ def main(argv):
             e = InputEvent(evdev)
             evbit = libevdev.evbit(e.evtype, e.evcode)
 
+            if evbit in tool_bits:
+                tool_bits[evbit] = e.value
+
             if args.use_st:
                 # Note: this relies on the EV_KEY events to come in before the
                 # x/y events, otherwise the last/first event in each slot will
@@ -190,16 +200,6 @@ def main(argv):
                     s.y = e.value
                     s.dirty = True
 
-            if (evbit == libevdev.EV_KEY.BTN_TOUCH or
-                    (evbit == libevdev.EV_KEY.BTN_TOOL_DOUBLETAP and nslots < 2) or
-                    (evbit == libevdev.EV_KEY.BTN_TOOL_TRIPLETAP and nslots < 3) or
-                    (evbit == libevdev.EV_KEY.BTN_TOOL_QUADTAP and nslots < 4) or
-                    (evbit == libevdev.EV_KEY.BTN_TOOL_QUINTTAP and nslots < 5)):
-                print('            {} {} {} {}'.format(marker_button,
-                                                       evbit.name,
-                                                       e.value,
-                                                       marker_button))
-
             if evbit == libevdev.EV_SYN.SYN_REPORT:
                 if last_time is None:
                     last_time = e.sec * 1000000 + e.usec
@@ -209,7 +209,22 @@ def main(argv):
                     tdelta = int((t - last_time) / 1000)  # ms
                     last_time = t
 
-                print("{:2d}.{:06d} {:+4d}ms: ".format(e.sec, e.usec, tdelta), end='')
+                tools = [
+                    (libevdev.EV_KEY.BTN_TOOL_QUINTTAP, 'QIN'),
+                    (libevdev.EV_KEY.BTN_TOOL_QUADTAP, 'QAD'),
+                    (libevdev.EV_KEY.BTN_TOOL_TRIPLETAP, 'TRI'),
+                    (libevdev.EV_KEY.BTN_TOOL_DOUBLETAP, 'DBL'),
+                    (libevdev.EV_KEY.BTN_TOUCH, 'TOU'),
+                ]
+
+                for bit, string in tools:
+                    if tool_bits[bit]:
+                        tool_state = string
+                        break
+                else:
+                    tool_state = '   '
+
+                print("{:2d}.{:06d} {:+5d}ms {}: ".format(e.sec, e.usec, tdelta, tool_state), end='')
                 for sl in [s for s in slots if s.used]:
                     if sl.state == SlotState.NONE:
                         print(marker_empty_slot, end='')