Fork to support Mouse boot protocol and steam controllers.
Fork of USBHOST by
Revision 11:ba29414a455e, committed 2017-08-31
- Comitter:
- Louise Newberry
- Date:
- Thu Aug 31 21:36:56 2017 +0100
- Parent:
- 10:89cf0de5f793
- Commit message:
- Add control write to select boot mode as mice require this to
guarentee boot reports are selected.
Changed in this revision
USBHostHID/USBHostMouse.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 89cf0de5f793 -r ba29414a455e USBHostHID/USBHostMouse.cpp --- a/USBHostHID/USBHostMouse.cpp Mon Aug 21 21:22:41 2017 +0000 +++ b/USBHostHID/USBHostMouse.cpp Thu Aug 31 21:36:56 2017 +0100 @@ -48,8 +48,12 @@ bool USBHostMouse::connect() { - int len_listen; - + int len_listen; + uint8_t rep_buf[] = + { + 0, + }; + if (dev_connected) { return true; } @@ -69,7 +73,7 @@ if (!int_in) break; - USB_INFO("New Mouse device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, mouse_intf); + USB_INFO("New Mouse device: VID:%04x PID:%04x [dev: %p - intf: %d %d]", dev->getVid(), dev->getPid(), dev, mouse_intf,int_in); dev->setName("Mouse", mouse_intf); host->registerDriver(dev, mouse_intf, this, &USBHostMouse::init); @@ -79,6 +83,12 @@ len_listen = sizeof(report); } } + + /* Call set protocol to select boot protocol, otherwise the device may use report mode! */ + printf("ret = %d\r\n",host->controlWrite( dev, USB_HOST_TO_DEVICE | USB_REQUEST_TYPE_CLASS | USB_RECIPIENT_INTERFACE, + 0x0b, 0x00, mouse_intf, rep_buf, 0)); + + int ret=host->interruptRead(dev, int_in, report, len_listen, false); MBED_ASSERT((ret==USB_TYPE_OK) || (ret ==USB_TYPE_PROCESSING) || (ret == USB_TYPE_FREE)); if ((ret==USB_TYPE_OK) || (ret ==USB_TYPE_PROCESSING)) @@ -96,7 +106,7 @@ void USBHostMouse::rxHandler() { int len_listen = int_in->getLengthTransferred(); int buttons_t, x_t, y_t, z_t; - /*{ + { int index; for (index=0;index < len_listen; index++) { @@ -104,11 +114,13 @@ } if (index>0) printf(" %x:%x \r\n",dev->getVid(), dev->getPid()); - }*/ + } // We really should be parsing the pid report but this is a good workaround // for my wireless mouse for now! - if (dev->getVid() == 0x62a && dev->getPid() == 0x4101) + // Or NOT! Turns out that you need to use Set Protocol to select boot protocol or + // the device may use report mode instead. + /*if (dev->getVid() == 0x62a && dev->getPid() == 0x4101) { buttons_t = report[1] & 0x07; x_t = (((int)report[3] & 0xf) << 8) + (report[2]); @@ -119,12 +131,12 @@ z_t = report[5]; } - else + else*/ { buttons_t = report[0] & 0x07; - x_t = report[1]; - y_t = report[2]; - z_t = report[3]; + x_t = (int8_t)report[1]; + y_t = (int8_t)report[2]; + z_t = (int8_t)report[3]; } if (len_listen !=0) {