summaryrefslogtreecommitdiff
path: root/hw/usb/hid-logitech-hidpp20.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-03-23 23:36:47 +0100
committerPeter Wu <peter@lekensteyn.nl>2014-03-23 23:36:47 +0100
commit5ae3eabba2c39b02775be614447dd8baf6ae2d5d (patch)
tree2dc1cfb22b6d8f4c17de2214e24d54387a55bd8c /hw/usb/hid-logitech-hidpp20.c
parent7c530e39d3f61761f4f5b97b4f61c83773151413 (diff)
downloadqemu-5ae3eabba2c39b02775be614447dd8baf6ae2d5d.tar.gz
unifying: implement feature FeatureSet, init for M525
Diffstat (limited to 'hw/usb/hid-logitech-hidpp20.c')
-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;
}
}