receiver: use feature numbers for reprogrammable key versions
This commit is contained in:
parent
aa8d2fcac4
commit
79606c530b
|
@ -586,10 +586,10 @@ class KeysArray:
|
||||||
def __init__(self, device, count):
|
def __init__(self, device, count):
|
||||||
assert device is not None
|
assert device is not None
|
||||||
self.device = device
|
self.device = device
|
||||||
if FEATURE.REPROG_CONTROLS in self.device.features:
|
if FEATURE.REPROG_CONTROLS_V4 in self.device.features:
|
||||||
self.keyversion = 1
|
self.keyversion = FEATURE.REPROG_CONTROLS_V4
|
||||||
elif FEATURE.REPROG_CONTROLS_V4 in self.device.features:
|
elif FEATURE.REPROG_CONTROLS_V2 in self.device.features:
|
||||||
self.keyversion = 4
|
self.keyversion = FEATURE.REPROG_CONTROLS_V2
|
||||||
else:
|
else:
|
||||||
if _log.isEnabledFor(_ERROR):
|
if _log.isEnabledFor(_ERROR):
|
||||||
_log.error(f'Trying to read keys on device {device} which has no REPROG_CONTROLS(_VX) support.')
|
_log.error(f'Trying to read keys on device {device} which has no REPROG_CONTROLS(_VX) support.')
|
||||||
|
@ -613,13 +613,13 @@ class KeysArray:
|
||||||
raise IndexError(index)
|
raise IndexError(index)
|
||||||
|
|
||||||
# TODO: add here additional variants for other REPROG_CONTROLS
|
# TODO: add here additional variants for other REPROG_CONTROLS
|
||||||
if self.keyversion == 1:
|
if self.keyversion == FEATURE.REPROG_CONTROLS_V2:
|
||||||
keydata = feature_request(self.device, FEATURE.REPROG_CONTROLS, 0x10, index)
|
keydata = feature_request(self.device, FEATURE.REPROG_CONTROLS_V2, 0x10, index)
|
||||||
if keydata:
|
if keydata:
|
||||||
cid, tid, flags = _unpack('!HHB', keydata[:5])
|
cid, tid, flags = _unpack('!HHB', keydata[:5])
|
||||||
self.keys[index] = ReprogrammableKey(self.device, index, cid, tid, flags)
|
self.keys[index] = ReprogrammableKey(self.device, index, cid, tid, flags)
|
||||||
self.cid_to_tid[cid] = tid
|
self.cid_to_tid[cid] = tid
|
||||||
elif self.keyversion == 4:
|
elif self.keyversion == FEATURE.REPROG_CONTROLS_V4:
|
||||||
keydata = feature_request(self.device, FEATURE.REPROG_CONTROLS_V4, 0x10, index)
|
keydata = feature_request(self.device, FEATURE.REPROG_CONTROLS_V4, 0x10, index)
|
||||||
if keydata:
|
if keydata:
|
||||||
cid, tid, flags1, pos, group, gmask, flags2 = _unpack('!HHBBBBB', keydata[:9])
|
cid, tid, flags1, pos, group, gmask, flags2 = _unpack('!HHBBBBB', keydata[:9])
|
||||||
|
@ -1230,8 +1230,8 @@ def decipher_voltage(voltage_report):
|
||||||
def get_keys(device):
|
def get_keys(device):
|
||||||
# TODO: add here additional variants for other REPROG_CONTROLS
|
# TODO: add here additional variants for other REPROG_CONTROLS
|
||||||
count = None
|
count = None
|
||||||
if FEATURE.REPROG_CONTROLS in device.features:
|
if FEATURE.REPROG_CONTROLS_V2 in device.features:
|
||||||
count = feature_request(device, FEATURE.REPROG_CONTROLS)
|
count = feature_request(device, FEATURE.REPROG_CONTROLS_V2)
|
||||||
elif FEATURE.REPROG_CONTROLS_V4 in device.features:
|
elif FEATURE.REPROG_CONTROLS_V4 in device.features:
|
||||||
count = feature_request(device, FEATURE.REPROG_CONTROLS_V4)
|
count = feature_request(device, FEATURE.REPROG_CONTROLS_V4)
|
||||||
if count:
|
if count:
|
||||||
|
|
|
@ -241,9 +241,9 @@ def _print_device(dev, num=None):
|
||||||
print(' Has %d reprogrammable keys:' % len(dev.keys))
|
print(' Has %d reprogrammable keys:' % len(dev.keys))
|
||||||
for k in dev.keys:
|
for k in dev.keys:
|
||||||
# TODO: add here additional variants for other REPROG_CONTROLS
|
# TODO: add here additional variants for other REPROG_CONTROLS
|
||||||
if dev.keys.keyversion == 1:
|
if dev.keys.keyversion == _hidpp20.FEATURE.REPROG_CONTROLS_V2:
|
||||||
print(' %2d: %-26s => %-27s %s' % (k.index, k.key, k.default_task, ', '.join(k.flags)))
|
print(' %2d: %-26s => %-27s %s' % (k.index, k.key, k.default_task, ', '.join(k.flags)))
|
||||||
if dev.keys.keyversion == 4:
|
if dev.keys.keyversion == _hidpp20.FEATURE.REPROG_CONTROLS_V4:
|
||||||
print(' %2d: %-26s, default: %-27s => %-26s' % (k.index, k.key, k.default_task, k.mapped_to))
|
print(' %2d: %-26s, default: %-27s => %-26s' % (k.index, k.key, k.default_task, k.mapped_to))
|
||||||
gmask_fmt = ','.join(k.group_mask)
|
gmask_fmt = ','.join(k.group_mask)
|
||||||
gmask_fmt = gmask_fmt if gmask_fmt else 'empty'
|
gmask_fmt = gmask_fmt if gmask_fmt else 'empty'
|
||||||
|
|
Loading…
Reference in New Issue