summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-08-19 00:52:23 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-08-22 22:59:27 +0200
commit180faa686fd4f1e507b22e1751afcaf563263bc3 (patch)
tree329b2f62da2a64532808d6bab559284799a84843
parent2ebf21aeec3cb42a15e97f86c5eee556f7c6e6fc (diff)
downloadupower-180faa686fd4f1e507b22e1751afcaf563263bc3.tar.gz
hidpp: remove unnecessary HID++ 2.0 code
The device name and type can be queried from the receiver which does not mind if a paired device is using HID++ 2.0 or 1.0. Therefore remove the hidpp20-specific code which also removes indirection of an uninitialised "map" variable. The following code was buggy: msg.feature_idx = map->idx; ... map = ...; if (map != NULL) { ... } ... priv->model = ...; It should have become: map = ...; if (map != NULL) { ... priv->model = ...; } ... but since the HID++ 2.0 code is not necessary, just remove it. Signed-off-by: Peter Wu <lekensteyn@gmail.com>
-rw-r--r--src/linux/hidpp-device.c79
1 files changed, 5 insertions, 74 deletions
diff --git a/src/linux/hidpp-device.c b/src/linux/hidpp-device.c
index 84e8375..91f99aa 100644
--- a/src/linux/hidpp-device.c
+++ b/src/linux/hidpp-device.c
@@ -579,7 +579,6 @@ hidpp_device_refresh (HidppDevice *device,
gboolean ret = TRUE;
GString *name = NULL;
HidppMessage msg = { };
- guint i;
guint len;
HidppDevicePrivate *priv = device->priv;
guchar error_code = 0;
@@ -664,9 +663,9 @@ hidpp_device_refresh (HidppDevice *device,
// hidpp_device_map_add (device,
// HIDPP_FEATURE_I_FIRMWARE_INFO,
// "IFirmwareInfo");
- hidpp_device_map_add (device,
- HIDPP_FEATURE_GET_DEVICE_NAME_TYPE,
- "GetDeviceNameType");
+// hidpp_device_map_add (device,
+// HIDPP_FEATURE_GET_DEVICE_NAME_TYPE,
+// "GetDeviceNameType");
hidpp_device_map_add (device,
HIDPP_FEATURE_BATTERY_LEVEL_STATUS,
"BatteryLevelStatus");
@@ -684,7 +683,7 @@ hidpp_device_refresh (HidppDevice *device,
/* the device type can always be queried using HID++ 1.0 on the
* receiver, regardless of the device version. */
- if (priv->version <= 1) {
+ if (priv->version <= 1 || priv->version == 2) {
msg.type = HIDPP_MSG_TYPE_SHORT;
msg.device_idx = HIDPP_RECEIVER_ADDRESS;
msg.feature_idx = HIDPP_READ_LONG_REGISTER;
@@ -718,40 +717,6 @@ hidpp_device_refresh (HidppDevice *device,
priv->kind = HIDPP_DEVICE_KIND_UNKNOWN;
break;
}
- } else if (priv->version == 2) {
-
- /* send a BatteryLevelStatus report */
- map = hidpp_device_map_get_by_feature (device, HIDPP_FEATURE_GET_DEVICE_NAME_TYPE);
- if (map != NULL) {
- msg.type = HIDPP_MSG_TYPE_SHORT;
- msg.device_idx = priv->device_idx;
- msg.feature_idx = map->idx;
- msg.function_idx = HIDPP_FEATURE_GET_DEVICE_NAME_TYPE_FN_GET_TYPE;
- msg.s.params[0] = 0x00;
- msg.s.params[1] = 0x00;
- msg.s.params[2] = 0x00;
- ret = hidpp_device_cmd (device,
- &msg, &msg,
- error);
- if (!ret)
- goto out;
- switch (msg.s.params[0]) {
- case 0: /* keyboard */
- case 2: /* numpad */
- priv->kind = HIDPP_DEVICE_KIND_KEYBOARD;
- break;
- case 3: /* mouse */
- case 4: /* touchpad */
- case 5: /* trackball */
- priv->kind = HIDPP_DEVICE_KIND_MOUSE;
- break;
- case 1: /* remote-control */
- case 6: /* presenter */
- case 7: /* receiver */
- priv->kind = HIDPP_DEVICE_KIND_UNKNOWN;
- break;
- }
- }
}
}
@@ -759,7 +724,7 @@ hidpp_device_refresh (HidppDevice *device,
if ((refresh_flags & HIDPP_REFRESH_FLAGS_MODEL) > 0) {
/* the device name can always be queried using HID++ 1.0 on the
* receiver, regardless of the device version. */
- if (priv->version <= 1) {
+ if (priv->version <= 1 || priv->version == 2) {
msg.type = HIDPP_MSG_TYPE_SHORT;
msg.device_idx = HIDPP_RECEIVER_ADDRESS;
msg.feature_idx = HIDPP_READ_LONG_REGISTER;
@@ -778,40 +743,6 @@ hidpp_device_refresh (HidppDevice *device,
name = g_string_new ("");
g_string_append_len (name, msg.l.params + 2, len);
priv->model = g_strdup (name->str);
- } else if (priv->version == 2) {
- msg.type = HIDPP_MSG_TYPE_SHORT;
- msg.device_idx = priv->device_idx;
- msg.feature_idx = map->idx;
- msg.function_idx = HIDPP_FEATURE_GET_DEVICE_NAME_TYPE_FN_GET_COUNT;
- msg.s.params[0] = 0x00;
- msg.s.params[1] = 0x00;
- msg.s.params[2] = 0x00;
- map = hidpp_device_map_get_by_feature (device, HIDPP_FEATURE_GET_DEVICE_NAME_TYPE);
- if (map != NULL) {
- ret = hidpp_device_cmd (device,
- &msg, &msg,
- error);
- if (!ret)
- goto out;
- }
- len = msg.s.params[0];
- name = g_string_new ("");
- for (i = 0; i < len; i +=4 ) {
- msg.type = HIDPP_MSG_TYPE_SHORT;
- msg.device_idx = priv->device_idx;
- msg.feature_idx = map->idx;
- msg.function_idx = HIDPP_FEATURE_GET_DEVICE_NAME_TYPE_FN_GET_NAME;
- msg.s.params[0] = i;
- msg.s.params[1] = 0x00;
- msg.s.params[2] = 0x00;
- ret = hidpp_device_cmd (device,
- &msg, &msg,
- error);
- if (!ret)
- goto out;
- g_string_append_len (name, msg.s.params, 4);
- }
- priv->model = g_strdup (name->str);
}
}