From 58585bfb19c594306a33cd77ce2eb0c68dff4a45 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 24 Aug 2015 13:48:02 +1000 Subject: [PATCH] hidpp10: switch the idx base to 1, not 0 Only two receiver-specific requests have a 0-based index, everything else wants 1-indexed devices. This currently makes it impossible to address wired devices with a device index of 0. Switch it around, so that we use a 1-based index. Signed-off-by: Peter Hutterer --- src/hidpp10.c | 2 +- src/hidpp10.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index ea0490da..14c90604 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -328,7 +328,7 @@ hidpp10_get_device_from_wpid(struct ratbag_device *device, uint16_t wpid, struct { int i, res; - for (i = 0; i < 6; i++) { + for (i = 1; i < 7; i++) { res = hidpp10_get_device_from_idx(device, i, dev); if (res) continue; diff --git a/src/hidpp10.h b/src/hidpp10.h index 92643eb8..2e862aba 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -93,14 +93,14 @@ .device_idx = RECEIVER_IDX, \ .sub_id = GET_LONG_REGISTER_REQ, \ .address = __CMD_PAIRING_INFORMATION, \ - .parameters = {type + idx, 0x00, 0x00 }, \ + .parameters = {type + idx - 1, 0x00, 0x00 }, \ } \ } #define CMD_DEVICE_FIRMWARE_INFORMATION(idx, fw_info_item) { \ .msg = { \ .report_id = REPORT_ID_SHORT, \ - .device_idx = idx + 1, \ + .device_idx = idx, \ .sub_id = GET_REGISTER_REQ, \ .address = __CMD_DEVICE_FIRMWARE_INFORMATION, \ .parameters = {fw_info_item, 0x00, 0x00 }, \ @@ -110,7 +110,7 @@ #define CMD_HIDPP_NOTIFICATIONS(idx, sub) { \ .msg = { \ .report_id = REPORT_ID_SHORT, \ - .device_idx = idx + 1, \ + .device_idx = idx, \ .sub_id = sub, \ .address = __CMD_HIDPP_NOTIFICATIONS, \ .parameters = {0x00, 0x00, 0x00 }, \ @@ -120,7 +120,7 @@ #define CMD_ENABLE_INDIVIDUAL_FEATURES(idx, sub) { \ .msg = { \ .report_id = REPORT_ID_SHORT, \ - .device_idx = idx + 1, \ + .device_idx = idx, \ .sub_id = sub, \ .address = __CMD_ENABLE_INDIVIDUAL_FEATURES, \ .parameters = {0x00, 0x00, 0x00 }, \ @@ -133,7 +133,7 @@ .device_idx = RECEIVER_IDX, \ .sub_id = SET_REGISTER_REQ, \ .address = __CMD_DEVICE_CONNECTION_DISCONNECTION, \ - .parameters = {cmd, idx, timeout }, \ + .parameters = {cmd, idx - 1, timeout }, \ } \ }