Division by zero in libinput-measure-touchpad-pressure Python code
When trying to ascertain the pressure ranges for a device with a very high sensitivity, a Logitech rechargeable touchpad, I got the following backtrace in the pressure measuring helper. Yep, sequences of zero length. Perhaps that __str__()
needs another case? Perhaps TouchSequence
needs to be a bit smarter or initialized only when there's at least one event.
Probably just a tools issue. I'm running Debian testing/unstable, libinput-tools version 1.10.7-1.
Steps to reproduce
- Own one of these touchpads. Synaptics ones I've tried are unaffected.
- Run
sudo libinput measure touchpad-pressure
. - Tap rapidly (a few times a second) and very gently (featherweight taps) until it happens.
Reliability: hardware-dependent, but I can manage it every time
The exceptions appear around output like
Sequence 16 pressure: min: 0 max: 0 avg: 0 median: 0 tags:
but it is possible to produce valid sequences of zero-pressure-only events with this device.
Backtrace
$ sudo libinput measure touchpad-pressure
[sudo] password for andrewc:
Using Logitech Rechargeable Touchpad T650: /dev/input/event16
Ready for recording data.
Pressure range used: 6:5
Palm pressure range used: 130
Place a single finger on the touchpad to measure pressure values.
Ctrl+C to exit
Sequence 653 pressure: min: 0 max: 15 avg: 7 median: 15 tags: down
Sequence 654 pressure: min: 0 max: 16 avg: 11 median: 12 tags: down
Sequence 655 pressure: min: 4 max: 12 avg: 8 median: 9 tags: down
Sequence 656 pressure: min: 0 max: 0 avg: 0 median: 0 tags:
Traceback (most recent call last):
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 299, in <module>
main(sys.argv)
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 289, in main
loop(device)
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 246, in loop
handle_event(device, event)
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 233, in handle_event
handle_abs(device, event)
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 224, in handle_abs
print("\r{}".format(s))
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 105, in __str__
return self._str_state() if self.is_active else self._str_summary()
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 114, in _str_summary
self.avg(),
File "/usr/lib/x86_64-linux-gnu/libinput/libinput-measure-touchpad-pressure", line 96, in avg
return int(sum([p.pressure for p in self.points])/len(self.points))
ZeroDivisionError: division by zero
Touchpad info
Just in case it's an underlying touchpad thing. Let me know if you need more.
$ sudo evemu-record
Available devices:
/dev/input/event0: AT Translated Set 2 keyboard
/dev/input/event1: Synaptics s3203
/dev/input/event2: SYNAPTICS Synaptics Large Touch Screen
/dev/input/event3: PS/2 Generic Mouse
/dev/input/event4: Power Button
/dev/input/event5: Lid Switch
/dev/input/event6: Power Button
/dev/input/event7: DELL Wireless hotkeys
/dev/input/event8: Dell WMI hotkeys
/dev/input/event9: Video Bus
/dev/input/event10: HDA Digital PCBeep
/dev/input/event11: HDA Intel PCH Headphone Mic
/dev/input/event12: HDA Intel HDMI HDMI/DP,pcm=3
/dev/input/event13: HDA Intel HDMI HDMI/DP,pcm=7
/dev/input/event14: HDA Intel HDMI HDMI/DP,pcm=8
/dev/input/event15: Integrated_Webcam_HD: Integrate
/dev/input/event16: Logitech Rechargeable Touchpad T650
Select the device event number [0-16]: 16
# EVEMU 1.3
# Kernel: 4.16.0-2-amd64
# DMI: dmi:bvnDellInc.:bvrA08:bd08/31/2015:svnDellInc.:pnXPS139333:pvr:rvnDellInc.:rn0D13CR:rvrA00:cvnDellInc.:ct8:cvr0.1:
# Input device name: "Logitech Rechargeable Touchpad T650"
# Input device ID: bus 0x03 vendor 0x46d product 0x4101 version 0x111
# Size in mm: 123x102
# Supported events:
# Event type 0 (EV_SYN)
# Event code 0 (SYN_REPORT)
# Event code 1 (SYN_CONFIG)
# Event code 2 (SYN_MT_REPORT)
# Event code 3 (SYN_DROPPED)
# Event code 4 ((null))
# Event code 5 ((null))
# Event code 6 ((null))
# Event code 7 ((null))
# Event code 8 ((null))
# Event code 9 ((null))
# Event code 10 ((null))
# Event code 11 ((null))
# Event code 12 ((null))
# Event code 13 ((null))
# Event code 14 ((null))
# Event code 15 (SYN_MAX)
# Event type 1 (EV_KEY)
# Event code 272 (BTN_LEFT)
# Event code 325 (BTN_TOOL_FINGER)
# Event code 328 (BTN_TOOL_QUINTTAP)
# Event code 330 (BTN_TOUCH)
# Event code 333 (BTN_TOOL_DOUBLETAP)
# Event code 334 (BTN_TOOL_TRIPLETAP)
# Event code 335 (BTN_TOOL_QUADTAP)
# Event type 3 (EV_ABS)
# Event code 0 (ABS_X)
# Value 1280
# Min 0
# Max 2832
# Fuzz 0
# Flat 0
# Resolution 23
# Event code 1 (ABS_Y)
# Value 1202
# Min 0
# Max 2364
# Fuzz 0
# Flat 0
# Resolution 23
# Event code 24 (ABS_PRESSURE)
# Value 0
# Min 0
# Max 50
# Fuzz 0
# Flat 0
# Resolution 0
# Event code 47 (ABS_MT_SLOT)
# Value 0
# Min 0
# Max 9
# Fuzz 0
# Flat 0
# Resolution 0
# Event code 53 (ABS_MT_POSITION_X)
# Value 0
# Min 0
# Max 2832
# Fuzz 0
# Flat 0
# Resolution 23
# Event code 54 (ABS_MT_POSITION_Y)
# Value 0
# Min 0
# Max 2364
# Fuzz 0
# Flat 0
# Resolution 23
# Event code 57 (ABS_MT_TRACKING_ID)
# Value 0
# Min 0
# Max 65535
# Fuzz 0
# Flat 0
# Resolution 0
# Event code 58 (ABS_MT_PRESSURE)
# Value 0
# Min 0
# Max 50
# Fuzz 0
# Flat 0
# Resolution 0
# Properties:
# Property type 0 (INPUT_PROP_POINTER)
# Property type 2 (INPUT_PROP_BUTTONPAD)
N: Logitech Rechargeable Touchpad T650
I: 0003 046d 4101 0111
P: 05 00 00 00 00 00 00 00
B: 00 0b 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 01 00 00 00 00 00
B: 01 20 e5 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 00 00 00 00 00 00 00 00
B: 03 03 00 00 01 00 80 60 06
B: 04 00 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 00 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 14 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
A: 00 0 2832 0 0 23
A: 01 0 2364 0 0 23
A: 18 0 50 0 0 0
A: 2f 0 9 0 0 0
A: 35 0 2832 0 0 23
A: 36 0 2364 0 0 23
A: 39 0 65535 0 0 0
A: 3a 0 50 0 0 0
################################
# Waiting for events #
################################
^C
$ udevadm info /dev/input/event16
P: /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.2/0003:046D:C52B.0009/0003:046D:4101.000A/input/input26/event16
N: input/event16
S: input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse
S: input/by-path/pci-0000:00:14.0-usb-0:1:1.2-event-mouse
E: DEVLINKS=/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse /dev/input/by-path/pci-0000:00:14.0-usb-0:1:1.2-event-mouse
E: DEVNAME=/dev/input/event16
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.2/0003:046D:C52B.0009/0003:046D:4101.000A/input/input26/event16
E: ID_BUS=usb
E: ID_INPUT=1
E: ID_INPUT_HEIGHT_MM=102
E: ID_INPUT_TOUCHPAD=1
E: ID_INPUT_TOUCHPAD_INTEGRATION=internal
E: ID_INPUT_WIDTH_MM=123
E: ID_MODEL=USB_Receiver
E: ID_MODEL_ENC=USB\x20Receiver
E: ID_MODEL_ID=c52b
E: ID_PATH=pci-0000:00:14.0-usb-0:1:1.2
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_1_1_2
E: ID_REVISION=2400
E: ID_SERIAL=Logitech_USB_Receiver
E: ID_TYPE=hid
E: ID_USB_DRIVER=usbhid
E: ID_USB_INTERFACES=:030101:030102:030000:
E: ID_USB_INTERFACE_NUM=02
E: ID_VENDOR=Logitech
E: ID_VENDOR_ENC=Logitech
E: ID_VENDOR_ID=046d
E: LIBINPUT_DEVICE_GROUP=3/46d/4101:usb-0000:00:14.0-1:1
E: MAJOR=13
E: MINOR=80
E: SUBSYSTEM=input
E: USEC_INITIALIZED=890245765
Vendor model “Rechargeable Touchpad T650” and P/N:810-003198.