logitech_receiver: add support to multiple range in Set action
This commit is contained in:
parent
13dfac476b
commit
5c96d2d307
|
@ -1118,7 +1118,19 @@ class MultipleRangeValidator(Validator):
|
||||||
return w + b'\xFF'
|
return w + b'\xFF'
|
||||||
|
|
||||||
def acceptable(self, args, current):
|
def acceptable(self, args, current):
|
||||||
pass # not implemented yet
|
# just one item, with at least one sub-item
|
||||||
|
if not isinstance(args, list) or len(args) != 2 or not isinstance(args[1], dict):
|
||||||
|
return None
|
||||||
|
item = next((p for p in self.items if p.id == args[0] or str(p) == args[0]), None)
|
||||||
|
if not item:
|
||||||
|
return None
|
||||||
|
for sub_key, value in args[1].items():
|
||||||
|
sub_item = next((it for it in self.sub_items[item] if it.id == sub_key), None)
|
||||||
|
if not sub_item:
|
||||||
|
return None
|
||||||
|
if not isinstance(value, int) or not (sub_item.minimum <= value <= sub_item.maximum):
|
||||||
|
return None
|
||||||
|
return [str(int(item)), {**args[1]}]
|
||||||
|
|
||||||
|
|
||||||
class ActionSettingRW:
|
class ActionSettingRW:
|
||||||
|
|
|
@ -947,7 +947,10 @@ class Gesture2Params(_LongSettings):
|
||||||
description = _('Change numerical parameters of a mouse/touchpad.')
|
description = _('Change numerical parameters of a mouse/touchpad.')
|
||||||
feature = _F.GESTURE_2
|
feature = _F.GESTURE_2
|
||||||
rw_options = {'read_fnid': 0x70, 'write_fnid': 0x80}
|
rw_options = {'read_fnid': 0x70, 'write_fnid': 0x80}
|
||||||
choices_universe = None
|
choices_universe = _hidpp20.PARAM
|
||||||
|
sub_items_universe = _hidpp20.SUB_PARAM
|
||||||
|
# item (NamedInt) -> list/tuple of objects that have the following attributes
|
||||||
|
# .id (sub-item text), .length (in bytes), .minimum and .maximum
|
||||||
|
|
||||||
_labels = _GESTURE2_PARAMS_LABELS
|
_labels = _GESTURE2_PARAMS_LABELS
|
||||||
_labels_sub = _GESTURE2_PARAMS_LABELS_SUB
|
_labels_sub = _GESTURE2_PARAMS_LABELS_SUB
|
||||||
|
|
Loading…
Reference in New Issue