summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/usb/hid-logitech-hidpp20.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/hw/usb/hid-logitech-hidpp20.c b/hw/usb/hid-logitech-hidpp20.c
index 371eaa6bdd..be1e02df53 100644
--- a/hw/usb/hid-logitech-hidpp20.c
+++ b/hw/usb/hid-logitech-hidpp20.c
@@ -44,8 +44,43 @@ struct HidppFeature {
hidpp_feature_cb_t callback;
};
+/* define a HID++ 2.0 feature with given name */
+#define HIDPP20_FEATURE(name) \
+ int name(LHidDevice *hd, Hidpp20Msg *msg, uint8_t fn, uint8_t *params)
+
+static HIDPP20_FEATURE(feat_featureset)
+{
+ const HidppFeature *feat;
+
+ switch (fn) {
+ case 0: /* GetCount */
+ params[0] = hd->info.features_count;
+ return 1;
+ case 1: /* featureID, featureType = GetFeatureId(featureIndex) */
+ 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;
+ return 3;
+ default:
+ return -HIDPP20_ERR_CODE_INVALID_FUNCTION_ID;
+ }
+}
+
+/* root feature not included! */
+static const HidppFeature features_m525[] = {
+ { 0x0001, 0, feat_featureset },
+};
+
void hidpp20_init_features(LHidDevice *hd) {
switch (hd->info.wireless_pid) {
+ case 0x4013:
+ hd->info.features = features_m525;
+ hd->info.features_count = ARRAY_SIZE(features_m525);
+ break;
}
}