Signed-off-by: Jan Vesely <jano.ves...@gmail.com> --- Tested on Ubuntu, Fedora, and HelenOS.
hw/usb/dev-hid.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 2966066..954cde1 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -55,9 +55,10 @@ enum { STR_PRODUCT_TABLET, STR_PRODUCT_KEYBOARD, STR_SERIALNUMBER, - STR_CONFIG_MOUSE, STR_CONFIG_TABLET, STR_CONFIG_KEYBOARD, + STR_CONFIG_MOUSE_FULL, + STR_CONFIG_MOUSE_HIGH, }; static const USBDescStrings desc_strings = { @@ -66,12 +67,13 @@ static const USBDescStrings desc_strings = { [STR_PRODUCT_TABLET] = "QEMU USB Tablet", [STR_PRODUCT_KEYBOARD] = "QEMU USB Keyboard", [STR_SERIALNUMBER] = "42", /* == remote wakeup works */ - [STR_CONFIG_MOUSE] = "HID Mouse", [STR_CONFIG_TABLET] = "HID Tablet", [STR_CONFIG_KEYBOARD] = "HID Keyboard", + [STR_CONFIG_MOUSE_FULL]= "HID Mouse Full speed configuration (usb 1.1)", + [STR_CONFIG_MOUSE_HIGH]= "HID Mouse High speed configuration (usb 2.0)", }; -static const USBDescIface desc_iface_mouse = { +static const USBDescIface desc_iface_mouse_full = { .bInterfaceNumber = 0, .bNumEndpoints = 1, .bInterfaceClass = USB_CLASS_HID, @@ -102,6 +104,37 @@ static const USBDescIface desc_iface_mouse = { }, }; +static const USBDescIface desc_iface_mouse_high = { + .bInterfaceNumber = 0, + .bNumEndpoints = 1, + .bInterfaceClass = USB_CLASS_HID, + .bInterfaceSubClass = 0x01, /* boot */ + .bInterfaceProtocol = 0x02, + .ndesc = 1, + .descs = (USBDescOther[]) { + { + /* HID descriptor */ + .data = (uint8_t[]) { + 0x09, /* u8 bLength */ + USB_DT_HID, /* u8 bDescriptorType */ + 0x01, 0x00, /* u16 HID_class */ + 0x00, /* u8 country_code */ + 0x01, /* u8 num_descriptors */ + USB_DT_REPORT, /* u8 type: Report */ + 52, 0, /* u16 len */ + }, + }, + }, + .eps = (USBDescEndpoint[]) { + { + .bEndpointAddress = USB_DIR_IN | 0x01, + .bmAttributes = USB_ENDPOINT_XFER_INT, + .wMaxPacketSize = 4, + .bInterval = 0x06, + }, + }, +}; + static const USBDescIface desc_iface_tablet = { .bInterfaceNumber = 0, .bNumEndpoints = 1, @@ -193,19 +226,36 @@ static const USBDescIface desc_iface_keyboard = { }, }; -static const USBDescDevice desc_device_mouse = { - .bcdUSB = 0x0100, +static const USBDescDevice desc_device_mouse_full = { + .bcdUSB = 0x0200, + .bMaxPacketSize0 = 8, + .bNumConfigurations = 1, + .confs = (USBDescConfig[]) { + { + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = STR_CONFIG_MOUSE_FULL, + .bmAttributes = 0xa0, + .bMaxPower = 50, + .nif = 1, + .ifs = &desc_iface_mouse_full, + }, + }, +}; + +static const USBDescDevice desc_device_mouse_high = { + .bcdUSB = 0x0200, .bMaxPacketSize0 = 8, .bNumConfigurations = 1, .confs = (USBDescConfig[]) { { .bNumInterfaces = 1, .bConfigurationValue = 1, - .iConfiguration = STR_CONFIG_MOUSE, + .iConfiguration = STR_CONFIG_MOUSE_HIGH, .bmAttributes = 0xa0, .bMaxPower = 50, .nif = 1, - .ifs = &desc_iface_mouse, + .ifs = &desc_iface_mouse_high, }, }, }; @@ -274,7 +324,8 @@ static const USBDesc desc_mouse = { .iProduct = STR_PRODUCT_MOUSE, .iSerialNumber = STR_SERIALNUMBER, }, - .full = &desc_device_mouse, + .full = &desc_device_mouse_full, + .high = &desc_device_mouse_high, .str = desc_strings, .msos = &desc_msos_suspend, }; -- 1.8.3.2