From 19e9d59b8d9c13ea75992058dd94387edb68a262 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Mon, 31 Mar 2014 12:50:40 +0200 Subject: unifying: fix HID++ 2.0 GetFeatureId indexing --- hw/usb/hid-logitech-hidpp20.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/usb/hid-logitech-hidpp20.c b/hw/usb/hid-logitech-hidpp20.c index a3a50e6cd3..b616989379 100644 --- a/hw/usb/hid-logitech-hidpp20.c +++ b/hw/usb/hid-logitech-hidpp20.c @@ -88,10 +88,14 @@ static HIDPP20_FEATURE(feat_featureset) if (params[0] > hd->info.features_count) { return -HIDPP20_ERR_CODE_OUTOFRANGE; } - feat = &hd->info.features[params[0]]; - params[0] = feat->id >> 8; - params[1] = (uint8_t) feat->id; - params[2] = feat->type; + if (params[0] == 0) { + memset(params, 0, 3); + } else { + feat = &hd->info.features[params[0] - 1]; + params[0] = feat->id >> 8; + params[1] = (uint8_t) feat->id; + params[2] = feat->type; + } return 3; default: return -HIDPP20_ERR_CODE_INVALID_FUNCTION_ID; -- cgit v1.2.1