diff options
-rw-r--r-- | hw/usb/dev-unifying.c | 20 | ||||
-rw-r--r-- | hw/usb/hid-logitech-dj.c | 4 | ||||
-rw-r--r-- | hw/usb/hid-logitech-dj.h | 2 |
3 files changed, 21 insertions, 5 deletions
diff --git a/hw/usb/dev-unifying.c b/hw/usb/dev-unifying.c index c9364f089c..926e2f7e56 100644 --- a/hw/usb/dev-unifying.c +++ b/hw/usb/dev-unifying.c @@ -366,7 +366,9 @@ static void usb_ltunify_handle_reset(USBDevice *dev) { USBLtunifyState *s = (USBLtunifyState *) dev; - hid_reset(&s->hid[IFACE_KBD]); + if (s->enable_kbd) { + hid_reset(&s->hid[IFACE_KBD]); + } hid_reset(&s->hid[IFACE_MSE]); hidpp_reset(s); } @@ -375,7 +377,12 @@ static void usb_ltunify_handle_control_hid(USBDevice *dev, USBPacket *p, int request, int value, int index, int length, uint8_t *data) { USBLtunifyState *s = (USBLtunifyState *) dev; - HIDState *hs = &s->hid[index]; + HIDState *hs = NULL; + + if (index == IFACE_KBD && !s->enable_kbd) { + goto fail; + } + hs = &s->hid[index]; switch (request) { case HID_GET_REPORT: @@ -569,7 +576,9 @@ static void usb_ltunify_handle_destroy(USBDevice *dev) USBLtunifyState *s = (USBLtunifyState *) dev; hid_free(&s->hid[IFACE_MSE]); - hid_free(&s->hid[IFACE_KBD]); + if (s->enable_kbd) { + hid_free(&s->hid[IFACE_KBD]); + } if (s->usb_dump_state) { usb_dump_cleanup(s->usb_dump_state); @@ -592,7 +601,9 @@ static int usb_ltunify_initfn(USBDevice *dev) /* the receiver supports multiple HID devices. Let's load some even if not * all of them are paired. */ - hid_init(&s->hid[IFACE_KBD], HID_KEYBOARD, usb_ltunify_hid_event); + if (s->enable_kbd) { + hid_init(&s->hid[IFACE_KBD], HID_KEYBOARD, usb_ltunify_hid_event); + } hid_init(&s->hid[IFACE_MSE], HID_MOUSE, usb_ltunify_hid_event); hidpp_init(s); @@ -609,6 +620,7 @@ static const VMStateDescription vmstate_usb_ltunify = { }; static Property usb_ltunify_properties[] = { + DEFINE_PROP_BOOL("kbd", USBLtunifyState, enable_kbd, true), DEFINE_PROP_STRING("usbdump", USBLtunifyState, usbdump_filename), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c index 5eea52fe81..f01a4f312f 100644 --- a/hw/usb/hid-logitech-dj.c +++ b/hw/usb/hid-logitech-dj.c @@ -639,6 +639,8 @@ void hidpp_init(USBLtunifyState *s) r->info.serial = 0x4c4f5354; r->info.version = (struct firmware_version) { 24, 0, 18, 0, 6 }; - hidpp_init_device(s, 1, DEVTYPE_KEYBOARD); + if (s->enable_kbd) { + hidpp_init_device(s, 1, DEVTYPE_KEYBOARD); + } hidpp_init_device(s, 2, DEVTYPE_MOUSE); } diff --git a/hw/usb/hid-logitech-dj.h b/hw/usb/hid-logitech-dj.h index 33c6d4404a..b2190932d4 100644 --- a/hw/usb/hid-logitech-dj.h +++ b/hw/usb/hid-logitech-dj.h @@ -253,6 +253,8 @@ typedef struct USBLtunifyState { UsbDumpState *usb_dump_state; HIDState hid[2]; /* HID devices (keyboard, mouse) */ + bool enable_kbd; + /* queue for HID++ requests and responses */ struct { HidppMsg reports[16]; |