From e245f00367c79bd1cd24e31b2a8a1efdb7192f04 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 1 Apr 2014 19:29:38 +0200 Subject: unifying: implement FeatureInfo (guessed). It seems to be used to mark the features which got replaced by this feature? Signed-off-by: Peter Wu --- hw/usb/hid-logitech-hidpp20.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/hw/usb/hid-logitech-hidpp20.c b/hw/usb/hid-logitech-hidpp20.c index 9795830628..c69f6fd9c0 100644 --- a/hw/usb/hid-logitech-hidpp20.c +++ b/hw/usb/hid-logitech-hidpp20.c @@ -238,8 +238,32 @@ static HIDPP20_FEATURE(feat_batterystatus) static HIDPP20_FEATURE(feat_featureinfo) { - return -HIDPP20_ERR_CODE_UNSUPPORTED; /* TODO: figure out */ + uint32_t feature_id; + const HidppFeature *feat = NULL; + int i; + switch (fn) { + case 0x00: /* ?? Checks whether a feature replaces another? */ + feature_id = (params[0] << 8) | params[1]; + params[0] = params[1] = 0; + + if (feature_id != 0x0000) { + for (i = 0; i < hd->info.features_count; i++) { + feat = &hd->info.features[i]; + if (feat->id == feature_id) { + break; + } + feat = NULL; + } + + if (feat == NULL) { + return -HIDPP20_ERR_CODE_INVALIDARGUMENT; + } + /* The feature_id and return value seem to be related (though it is + * not treate specially here): 2101 -> 2100, 6110 -> 6000, + * 1b03 -> 1b00, 6100 -> 6000, 1b01 -> 1b00, 18e5 -> 1800 */ + } + return 2; default: return -HIDPP20_ERR_CODE_INVALID_FUNCTION_ID; } -- cgit v1.2.1