Commit c21c583a1de9c1033252ef51929398ddc237a7c0
1 parent
0266f2c7
Fix USB and HID report descriptors for mouse and tablet.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4253 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
17 additions
and
18 deletions
hw/usb-hid.c
| ... | ... | @@ -134,14 +134,14 @@ static const uint8_t qemu_mouse_config_descriptor[] = { |
| 134 | 134 | 0x00, /* u8 country_code */ |
| 135 | 135 | 0x01, /* u8 num_descriptors */ |
| 136 | 136 | 0x22, /* u8 type; Report */ |
| 137 | - 50, 0, /* u16 len */ | |
| 137 | + 52, 0, /* u16 len */ | |
| 138 | 138 | |
| 139 | 139 | /* one endpoint (status change endpoint) */ |
| 140 | 140 | 0x07, /* u8 ep_bLength; */ |
| 141 | 141 | 0x05, /* u8 ep_bDescriptorType; Endpoint */ |
| 142 | 142 | 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ |
| 143 | 143 | 0x03, /* u8 ep_bmAttributes; Interrupt */ |
| 144 | - 0x03, 0x00, /* u16 ep_wMaxPacketSize; */ | |
| 144 | + 0x04, 0x00, /* u16 ep_wMaxPacketSize; */ | |
| 145 | 145 | 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ |
| 146 | 146 | }; |
| 147 | 147 | |
| ... | ... | @@ -260,16 +260,14 @@ static const uint8_t qemu_mouse_hid_report_descriptor[] = { |
| 260 | 260 | 0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, |
| 261 | 261 | 0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, |
| 262 | 262 | 0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, |
| 263 | - 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, | |
| 264 | - 0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, | |
| 265 | - 0x05, 0x01, 0x09, 0x38, 0x15, 0x81, 0x25, 0x7F, | |
| 266 | - 0x35, 0x00, 0x45, 0x00, 0x75, 0x08, 0x95, 0x01, | |
| 267 | - 0x81, 0x02, 0xC0, 0xC0, | |
| 263 | + 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x09, 0x38, | |
| 264 | + 0x15, 0x81, 0x25, 0x7F, 0x75, 0x08, 0x95, 0x03, | |
| 265 | + 0x81, 0x06, 0xC0, 0xC0, | |
| 268 | 266 | }; |
| 269 | 267 | |
| 270 | 268 | static const uint8_t qemu_tablet_hid_report_descriptor[] = { |
| 271 | 269 | 0x05, 0x01, /* Usage Page Generic Desktop */ |
| 272 | - 0x09, 0x01, /* Usage Mouse */ | |
| 270 | + 0x09, 0x01, /* Usage Pointer */ | |
| 273 | 271 | 0xA1, 0x01, /* Collection Application */ |
| 274 | 272 | 0x09, 0x01, /* Usage Pointer */ |
| 275 | 273 | 0xA1, 0x00, /* Collection Physical */ |
| ... | ... | @@ -283,7 +281,7 @@ static const uint8_t qemu_tablet_hid_report_descriptor[] = { |
| 283 | 281 | 0x81, 0x02, /* Input (Data, Var, Abs) */ |
| 284 | 282 | 0x95, 0x01, /* Report Count 1 */ |
| 285 | 283 | 0x75, 0x05, /* Report Size 5 */ |
| 286 | - 0x81, 0x01, /* Input (Cnst, Var, Abs) */ | |
| 284 | + 0x81, 0x01, /* Input (Cnst, Array, Abs) */ | |
| 287 | 285 | 0x05, 0x01, /* Usage Page Generic Desktop */ |
| 288 | 286 | 0x09, 0x30, /* Usage X */ |
| 289 | 287 | 0x09, 0x31, /* Usage Y */ |
| ... | ... | @@ -302,7 +300,7 @@ static const uint8_t qemu_tablet_hid_report_descriptor[] = { |
| 302 | 300 | 0x45, 0x00, /* Physical Maximum 0 (same as logical) */ |
| 303 | 301 | 0x75, 0x08, /* Report Size 8 */ |
| 304 | 302 | 0x95, 0x01, /* Report Count 1 */ |
| 305 | - 0x81, 0x02, /* Input (Data, Var, Rel) */ | |
| 303 | + 0x81, 0x06, /* Input (Data, Var, Rel) */ | |
| 306 | 304 | 0xC0, /* End Collection */ |
| 307 | 305 | 0xC0, /* End Collection */ |
| 308 | 306 | }; |
| ... | ... | @@ -495,14 +493,15 @@ static int usb_mouse_poll(USBHIDState *hs, uint8_t *buf, int len) |
| 495 | 493 | if (s->buttons_state & MOUSE_EVENT_MBUTTON) |
| 496 | 494 | b |= 0x04; |
| 497 | 495 | |
| 498 | - buf[0] = b; | |
| 499 | - buf[1] = dx; | |
| 500 | - buf[2] = dy; | |
| 501 | - l = 3; | |
| 502 | - if (len >= 4) { | |
| 503 | - buf[3] = dz; | |
| 504 | - l = 4; | |
| 505 | - } | |
| 496 | + l = 0; | |
| 497 | + if (len > l) | |
| 498 | + buf[l ++] = b; | |
| 499 | + if (len > l) | |
| 500 | + buf[l ++] = dx; | |
| 501 | + if (len > l) | |
| 502 | + buf[l ++] = dy; | |
| 503 | + if (len > l) | |
| 504 | + buf[l ++] = dz; | |
| 506 | 505 | return l; |
| 507 | 506 | } |
| 508 | 507 | ... | ... |