Fork to support Mouse boot protocol and steam controllers.
Fork of USBHOST by
Diff: USBHostHID/USBHostSteamController.cpp
- Revision:
- 9:6bbea1ccc9f8
- Parent:
- 8:e57ccb876952
- Child:
- 10:89cf0de5f793
--- a/USBHostHID/USBHostSteamController.cpp Sat Aug 19 19:47:53 2017 +0000 +++ b/USBHostHID/USBHostSteamController.cpp Sun Aug 20 13:55:46 2017 +0000 @@ -64,6 +64,7 @@ break; if (mouse_device_found) { { + printf("found!"); /* As this is done in a specific thread * this lock is taken to avoid to process the device * disconnect in usb process during the device registering */ @@ -71,9 +72,8 @@ int_in = dev->getEndpoint(mouse_intf, INTERRUPT_ENDPOINT, IN); if (!int_in) break; - - USB_INFO("New Mouse device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, mouse_intf); - dev->setName("Mouse", mouse_intf); + USB_INFO("New SteamController device: VID:%04x PID:%04x [dev: %p - intf: %d]", dev->getVid(), dev->getPid(), dev, mouse_intf); + dev->setName("Steam", mouse_intf); host->registerDriver(dev, mouse_intf, this, &USBHostSteamController::init); int_in->attach(this, &USBHostSteamController::rxHandler); @@ -99,40 +99,33 @@ void USBHostSteamController::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++) { printf("%2x ",report[index]); } - if (index>0) printf(" %x:%x \r\n",dev->getVid(), dev->getPid()); - } + if (index>0) printf(" %x:%x %d\r\n",dev->getVid(), dev->getPid(),len_listen); + }*/ - if (report[2] != 1) - { - return; - } - - // We really should be parsing the pid report but this is a good workaround - // for my wireless mouse for now! - buttons_t = report[8] + (report[9] << 8) + (report[10] << 16); // << 4; - x_t = report[17]; // report[16] lsb - y_t = report[19]; // report[18] lsb + if ((len_listen !=0) && (report[2] == 1)) + { + buttons_t = report[8] + (report[9] << 8) + (report[10] << 16); // << 4; + x_t = report[17]; // report[16] lsb + y_t = report[19]; // report[18] lsb + + z_t = 0; //report[4]; - z_t = 0; //report[4]; - - right_pad_x = (report[21] << 8) + report[20]; - right_pad_y = (report[23] << 8) + report[22]; - - if (len_listen !=0) { + right_pad_x = (report[21] << 8) + report[20]; + right_pad_y = (report[23] << 8) + report[22]; if (onUpdate) { (*onUpdate)(buttons_t, x_t, y_t, right_pad_x, right_pad_y); } - if (onButtonUpdate && (buttons != (report[0]))) { +/* if (onButtonUpdate && (buttons != (report[0]))) { (*onButtonUpdate)(report[0]); } @@ -146,7 +139,7 @@ if (onZUpdate && (z != report[3])) { (*onZUpdate)(z_t); - } + }*/ // update mouse state buttons = buttons_t; @@ -172,13 +165,15 @@ /*virtual*/ bool USBHostSteamController::parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) //Must return true if the interface should be parsed { - //printf("intf_class %x intf_subclass %x intf_protocol %x\r\n", intf_class,intf_subclass, intf_protocol); + printf("intf_nb %d (%d) intf_class %x intf_subclass %x intf_protocol %x\r\n", intf_nb, mouse_intf, intf_class,intf_subclass, intf_protocol); if ((mouse_intf == -1) && (intf_class == HID_CLASS) && (intf_subclass == 0x00) && (intf_protocol == 0x00)) { mouse_intf = intf_nb; + + printf("true!"); return true; } return false;