Repository: pwr-Solaar/Solaar

Issue:
ADJUSTABLE_DPI not being reported in solaar show
ADJUSTABLE_DPI is adjustable in Solaar but not reported by solaar show
See #686 for sample output.


Discussion:

Resolving patch:
diff --git a/lib/logitech_receiver/settings.py b/lib/logitech_receiver/settings.py
--- a/lib/logitech_receiver/settings.py
+++ b/lib/logitech_receiver/settings.py
@@ -42,15 +42,16 @@
 class Setting(object):
 	"""A setting descriptor.
 	Needs to be instantiated for each specific device."""
-	__slots__ = ('name', 'label', 'description', 'kind', 'device_kind',
+	__slots__ = ('name', 'label', 'description', 'kind', 'device_kind', 'feature', 
 					'_rw', '_validator', '_device', '_value')
 
-	def __init__(self, name, rw, validator, kind=None, label=None, description=None, device_kind=None):
+	def __init__(self, name, rw, validator, kind=None, label=None, description=None, device_kind=None, feature=None):
 		assert name
 		self.name = name
 		self.label = label or name
 		self.description = description
 		self.device_kind = device_kind
+		self.feature = feature
 
 		self._rw = rw
 		self._validator = validator
diff --git a/lib/logitech_receiver/settings_templates.py b/lib/logitech_receiver/settings_templates.py
--- a/lib/logitech_receiver/settings_templates.py
+++ b/lib/logitech_receiver/settings_templates.py
@@ -78,7 +78,7 @@ def feature_toggle(name, feature,
 					label=None, description=None, device_kind=None):
 	validator = _BooleanV(true_value=true_value, false_value=false_value, mask=mask)
 	rw = _FeatureRW(feature, read_function_id, write_function_id)
-	return _Setting(name, rw, validator, label=label, description=description, device_kind=device_kind)
+	return _Setting(name, rw, validator, feature=feature, label=label, description=description, device_kind=device_kind)
 
 def feature_choices(name, feature, choices,
 					read_function_id, write_function_id,
@@ -87,7 +87,7 @@ def feature_choices(name, feature, choices,
 	assert choices
 	validator = _ChoicesV(choices, bytes_count=bytes_count)
 	rw = _FeatureRW(feature, read_function_id, write_function_id)
-	return _Setting(name, rw, validator, kind=_KIND.choice, label=label, description=description, device_kind=device_kind)
+	return _Setting(name, rw, validator, feature=feature, kind=_KIND.choice, label=label, description=description, device_kind=device_kind)
 
 def feature_choices_dynamic(name, feature, choices_callback,
 					read_function_id, write_function_id,
@@ -113,7 +113,7 @@ def feature_range(name, feature, min_value, max_value,
 	validator = _RangeV(min_value, max_value, bytes_count=bytes_count)
 	if rw is None:
 		rw = _FeatureRW(feature, read_function_id, write_function_id)
-	return _Setting(name, rw, validator, kind=_KIND.range, label=label, description=description, device_kind=device_kind)
+	return _Setting(name, rw, validator, feature=feature, kind=_KIND.range, label=label, description=description, device_kind=device_kind)
 
 #
 # common strings for settings
diff --git a/lib/solaar/cli/show.py b/lib/solaar/cli/show.py
--- a/lib/solaar/cli/show.py
+++ b/lib/solaar/cli/show.py
@@ -24,6 +24,7 @@
 				hidpp10 as _hidpp10,
 				hidpp20 as _hidpp20,
 				special_keys as _special_keys,
+				settings_templates as _settings_templates
 			)
 
 
@@ -91,6 +92,9 @@ def _print_device(dev):
 
 	if dev.online and dev.features:
 		print ('     Supports %d HID++ 2.0 features:' % len(dev.features))
+		dev.persister = None  # Give the device a fake persister
+		dev_settings = []
+		_settings_templates.check_feature_settings(dev, dev_settings)
 		for index, feature in enumerate(dev.features):
 			feature = dev.features[index]
 			flags = dev.request(0x0000, feature.bytes(2))
@@ -122,7 +126,7 @@ def _print_device(dev):
 						print("            HID++ notification")
 					else:
 						print("            HID notification")
-			if feature == _hidpp20.FEATURE.MOUSE_POINTER:
+			elif feature == _hidpp20.FEATURE.MOUSE_POINTER:
 				mouse_pointer = _hidpp20.get_mouse_pointer_info(dev)
 				if mouse_pointer:
 					print("            DPI: %s" % mouse_pointer['dpi'])
@@ -141,7 +145,7 @@ def _print_device(dev):
 					print("            Roller type: %s" % vertical_scrolling_info['roller'])
 					print("            Ratchet per turn: %s" % vertical_scrolling_info['ratchet'])
 					print("            Scroll lines: %s" % vertical_scrolling_info['lines'])
-			if feature == _hidpp20.FEATURE.HI_RES_SCROLLING:
+			elif feature == _hidpp20.FEATURE.HI_RES_SCROLLING:
 				scrolling_mode, scrolling_resolution = _hidpp20.get_hi_res_scrolling_info(dev)
 				if scrolling_mode:
 					print("            Hi-res scrolling enabled")
@@ -149,14 +153,19 @@ def _print_device(dev):
 					print("            Hi-res scrolling disabled")
 				if scrolling_resolution:
 					print("            Hi-res scrolling multiplier: %s" % scrolling_resolution)
-			if feature == _hidpp20.FEATURE.POINTER_SPEED:
+			elif feature == _hidpp20.FEATURE.POINTER_SPEED:
 				pointer_speed = _hidpp20.get_pointer_speed_info(dev)
 				if pointer_speed:
 					print("            Pointer Speed: %s" % pointer_speed)
-			if feature == _hidpp20.FEATURE.LOWRES_WHEEL:
-				wheel_status = _hidpp20.get_lowres_wheel_status(dev)
-				if wheel_status:
-					print("            Wheel Reports: %s" % wheel_status)
+#			elif feature == _hidpp20.FEATURE.LOWRES_WHEEL:
+#				wheel_status = _hidpp20.get_lowres_wheel_status(dev)
+#				if wheel_status:
+#					print("            Wheel Reports: %s" % wheel_status)
+			else: 
+				for setting in dev_settings:
+					if setting.feature == feature:
+						v = setting.read(False)
+						print("            %s: %s" % (setting.label, v) )
 
 	if dev.online and dev.keys:
 		print ('     Has %d reprogrammable keys:' % len(dev.keys))


Test patch: