From b1af7496b1a37bdf10e4e940206ab1845bfd08cb Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Wed, 28 Jun 2017 14:19:11 +0100 Subject: [PATCH] unifying: Show the hardware version when the hardware provides this --- plugins/unifying/lu-device-peripheral.c | 3 +++ plugins/unifying/lu-device.c | 19 +++++++++++++++++++ plugins/unifying/lu-device.h | 3 +++ 3 files changed, 25 insertions(+) diff --git a/plugins/unifying/lu-device-peripheral.c b/plugins/unifying/lu-device-peripheral.c index 4f0050c8b..96e63b57c 100644 --- a/plugins/unifying/lu-device-peripheral.c +++ b/plugins/unifying/lu-device-peripheral.c @@ -58,6 +58,7 @@ lu_device_peripheral_fetch_firmware_info (LuDevice *device, GError **error) return FALSE; } entity_count = msg->data[0]; + g_debug ("firmware entity count is %u", entity_count); /* get firmware, bootloader, hardware versions */ for (guint8 i = 0; i < entity_count; i++) { @@ -100,6 +101,8 @@ lu_device_peripheral_fetch_firmware_info (LuDevice *device, GError **error) self->cached_fw_entity = i; } else if (msg->data[0] == 1) { lu_device_set_version_bl (device, version); + } else if (msg->data[0] == 2) { + lu_device_set_version_hw (device, version); } } diff --git a/plugins/unifying/lu-device.c b/plugins/unifying/lu-device.c index 5a951d00a..0bf9565a1 100644 --- a/plugins/unifying/lu-device.c +++ b/plugins/unifying/lu-device.c @@ -43,6 +43,7 @@ typedef struct gchar *vendor; gchar *version_bl; gchar *version_fw; + gchar *version_hw; GPtrArray *guids; LuDeviceFlags flags; guint8 hidpp_id; @@ -184,6 +185,8 @@ lu_device_to_string (LuDevice *device) g_string_append_printf (str, "version-bootloader:\t%s\n", priv->version_bl); if (priv->version_fw != NULL) g_string_append_printf (str, "version-firmware:\t%s\n", priv->version_fw); + if (priv->version_hw != NULL) + g_string_append_printf (str, "version-hardware:\t%s\n", priv->version_hw); for (guint i = 0; i < priv->guids->len; i++) { const gchar *guid = g_ptr_array_index (priv->guids, i); g_string_append_printf (str, "guid:\t\t\t%s\n", guid); @@ -819,6 +822,21 @@ lu_device_set_version_fw (LuDevice *device, const gchar *version_fw) priv->version_fw = g_strdup (version_fw); } +const gchar * +lu_device_get_version_hw (LuDevice *device) +{ + LuDevicePrivate *priv = GET_PRIVATE (device); + return priv->version_hw; +} + +void +lu_device_set_version_hw (LuDevice *device, const gchar *version_hw) +{ + LuDevicePrivate *priv = GET_PRIVATE (device); + g_free (priv->version_hw); + priv->version_hw = g_strdup (version_hw); +} + GPtrArray * lu_device_get_guids (LuDevice *device) { @@ -1293,6 +1311,7 @@ lu_device_finalize (GObject *object) g_free (priv->product); g_free (priv->vendor); g_free (priv->version_fw); + g_free (priv->version_hw); g_free (priv->version_bl); G_OBJECT_CLASS (lu_device_parent_class)->finalize (object); diff --git a/plugins/unifying/lu-device.h b/plugins/unifying/lu-device.h index a9e6e9cf5..0fea679fa 100644 --- a/plugins/unifying/lu-device.h +++ b/plugins/unifying/lu-device.h @@ -152,6 +152,9 @@ void lu_device_set_version_bl (LuDevice *device, const gchar *lu_device_get_version_fw (LuDevice *device); void lu_device_set_version_fw (LuDevice *device, const gchar *version_fw); +const gchar *lu_device_get_version_hw (LuDevice *device); +void lu_device_set_version_hw (LuDevice *device, + const gchar *version_hw); GPtrArray *lu_device_get_guids (LuDevice *device); void lu_device_add_guid (LuDevice *device, const gchar *guid);