receiver: add model and node ID and use in configurations

This commit is contained in:
Peter F. Patel-Schneider 2020-09-18 17:18:46 -04:00
parent fc59c0fbf6
commit 1e7050595e
1 changed files with 25 additions and 16 deletions

View File

@ -405,6 +405,9 @@ def _device_selected(selection):
def _receiver_row(receiver_path, receiver=None): def _receiver_row(receiver_path, receiver=None):
assert receiver_path assert receiver_path
r = _model.get_iter_first()
while r:
r = _model.iter_next(r)
item = _model.get_iter_first() item = _model.get_iter_first()
while item: while item:
@ -433,21 +436,25 @@ def _device_row(receiver_path, device_number, device=None):
assert device_number is not None assert device_number is not None
receiver_row = _receiver_row(receiver_path, None if device is None else device.receiver) receiver_row = _receiver_row(receiver_path, None if device is None else device.receiver)
if receiver_row and device_number == 0: # wired device, receiver row is device row
return receiver_row
item = _model.iter_children(receiver_row) if device_number == 0: # direct-connected device, receiver row is device row
new_child_index = 0 if receiver_row:
while item: return receiver_row
assert _model.get_value(item, _COLUMN.PATH) == receiver_path item = None
item_number = _model.get_value(item, _COLUMN.NUMBER) new_child_index = 0
if item_number == device_number: else:
return item item = _model.iter_children(receiver_row)
if item_number > device_number: new_child_index = 0
item = None while item:
break assert _model.get_value(item, _COLUMN.PATH) == receiver_path
new_child_index += 1 item_number = _model.get_value(item, _COLUMN.NUMBER)
item = _model.iter_next(item) if item_number == device_number:
return item
if item_number > device_number:
item = None
break
new_child_index += 1
item = _model.iter_next(item)
if not item and device: if not item and device:
icon_name = _icons.device_icon_name(device.name, device.kind) icon_name = _icons.device_icon_name(device.name, device.kind)
@ -527,7 +534,7 @@ def _update_details(button):
yield (_('Path'), device.path) yield (_('Path'), device.path)
if device.kind is None: if device.kind is None:
# 046d is the Logitech vendor id # 046d is the Logitech vendor id
yield (_('USB id'), '046d:' + device.product_id) yield (_('USB ID'), '046d:' + device.product_id)
if read_all: if read_all:
yield (_('Serial'), device.serial) yield (_('Serial'), device.serial)
@ -540,7 +547,7 @@ def _update_details(button):
if device.wpid: if device.wpid:
yield (_('Wireless PID'), device.wpid) yield (_('Wireless PID'), device.wpid)
if device.product_id: if device.product_id:
yield (_('USB id'), '046d:' + device.product_id) yield (_('Product ID'), '046d:' + device.product_id)
hid_version = device.protocol hid_version = device.protocol
yield (_('Protocol'), 'HID++ %1.1f' % hid_version if hid_version else _('Unknown')) yield (_('Protocol'), 'HID++ %1.1f' % hid_version if hid_version else _('Unknown'))
if read_all and device.polling_rate: if read_all and device.polling_rate:
@ -555,6 +562,8 @@ def _update_details(button):
yield (_('Serial'), device.serial) yield (_('Serial'), device.serial)
else: else:
yield (_('Serial'), '...') yield (_('Serial'), '...')
if read_all and device.unitId and device.unitId != device.serial:
yield (_('Unit ID'), device.unitId)
if read_all: if read_all:
if device.firmware: if device.firmware: