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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2015-08-24 13:48:02 +10:00
parent f5df7f0ec9
commit 58585bfb19
2 changed files with 6 additions and 6 deletions

View File

@@ -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;

View File

@@ -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 }, \
} \
}