@@ -37,8 +37,7 @@ def get_args():
37
37
def get_service_name (udevreturn , input_dev ):
38
38
service = None
39
39
try :
40
- devpath = [line .split ("=" , 1 )[1 ] for line in udevreturn .splitlines ()
41
- if line .startswith ("DEVPATH=" )][0 ]
40
+ devpath = udevreturn .get ("DEVPATH" )
42
41
with open (f"/sys/{ devpath } /device/capabilities/abs" , "r" ) as f :
43
42
abs_string = f .read ().strip ()
44
43
# we care about only the last byte - that's where X,Y axies are
@@ -49,7 +48,7 @@ def get_service_name(udevreturn, input_dev):
49
48
('ID_INPUT_TABLET' in udevreturn ) or
50
49
('ID_INPUT_TOUCHSCREEN' in udevreturn ) or
51
50
('ID_INPUT_TOUCHPAD' in udevreturn ) or
52
- ('QEMU_USB_Tablet' in udevreturn )
51
+ ('QEMU_USB_Tablet' in udevreturn . get ( "ID_MODEL" ) )
53
52
) and 'ID_INPUT_KEY' not in udevreturn :
54
53
service = 'qubes-input-sender-tablet'
55
54
# if mouse report absolute events, prefer tablet service
@@ -106,31 +105,37 @@ def handle_event(input_dev, action, dom0):
106
105
udevreturn = subprocess .check_output ([
107
106
"udevadm" , "info" , "--query=property" ,
108
107
"--name=" + eventFile ]).decode ()
109
- if 'ID_TYPE=video' in udevreturn :
108
+ udevreturn = dict (
109
+ item .split ("=" , 1 )
110
+ for item in udevreturn .splitlines ()
111
+ )
112
+ if udevreturn .get ('ID_TYPE' ) == 'video' :
110
113
return
111
114
# The ID_SERIAL here corresponds to qemu-emulated tablet
112
115
# device for HVM which is static. It allows to attach another
113
116
# tablet for example when using KVM for tests. Depending on
114
117
# QEMU version, the device may look different. But it will
115
118
# always be the first bus, either on 00:04.0 or 00:05.0.
116
- if ('ID_PATH=pci-0000:00:04.0-usb-0:1:1.0' in udevreturn or \
117
- 'ID_PATH=pci-0000:00:05.0-usb-0:1:1.0' in udevreturn ) and \
118
- 'ID_SERIAL=QEMU_QEMU_USB_Tablet_' in udevreturn :
119
+ if udevreturn .get ('ID_PATH' ) in (
120
+ 'pci-0000:00:04.0-usb-0:1:1.0' ,
121
+ 'pci-0000:00:05.0-usb-0:1:1.0' ) and \
122
+ udevreturn .get ('ID_SERIAL' , '' ).startswith ('QEMU_QEMU_USB_Tablet' ):
119
123
return
120
- if ' /devices/virtual/' in udevreturn and dom0 :
124
+ if udevreturn . get ( 'DEVPATH' , '' ). startswith ( ' /devices/virtual/') and dom0 :
121
125
return
122
126
# exclude qubes virtual input device created by gui agent
123
- if 'TAGS= :qubes-virtual-input-device:' in udevreturn :
127
+ if udevreturn . get ( 'TAGS' ) == ' :qubes-virtual-input-device:' :
124
128
return
125
129
# We exclude in sys-usb ID_PATH=acpi-* and ID_PATH=platform-*
126
130
# which can correspond to power-switch buttons. By default, HVM
127
131
# exposes some so there is no point for adding input devices
128
132
# into dom0 from those. This is only pertinent in the case
129
133
# of dom0 key devices to sys-gui-gpu
130
- if 'ID_PATH=acpi-' in udevreturn and not dom0 :
131
- return
132
- if 'ID_PATH=platform-' in udevreturn and not dom0 :
133
- return
134
+ if not dom0 :
135
+ if udevreturn .get ('ID_PATH' , '' ).startswith ('acpi-' ):
136
+ return
137
+ if udevreturn .get ('ID_PATH' , '' ).startswith ('platform-' ):
138
+ return
134
139
elif action == "remove" :
135
140
# on remove action we use information passed through
136
141
# env by udev
0 commit comments