Added TARGET_DISCO_F469NI in USBHOST\USBHost\TARGET_STM\USBHALHost_STM_TARGET.h
Dependents: DISCO-F469NI_USB_Disk STM32F4xx_USB_Memory
Fork of USBHOST by
Diff: USBHostHID/USBHostMouse.cpp
- Revision:
- 8:3e7a33f81048
- Parent:
- 5:fc157e6bd5a5
diff -r 7ebd364a6be5 -r 3e7a33f81048 USBHostHID/USBHostMouse.cpp --- a/USBHostHID/USBHostMouse.cpp Mon Apr 30 05:37:24 2018 +0000 +++ b/USBHostHID/USBHostMouse.cpp Sat Jan 04 23:30:59 2020 +0000 @@ -18,12 +18,14 @@ #if USBHOST_MOUSE -USBHostMouse::USBHostMouse() { +USBHostMouse::USBHostMouse() +{ host = USBHost::getHostInst(); init(); } -void USBHostMouse::init() { +void USBHostMouse::init() +{ dev = NULL; int_in = NULL; onUpdate = NULL; @@ -42,7 +44,8 @@ z = 0; } -bool USBHostMouse::connected() { +bool USBHostMouse::connected() +{ return dev_connected; } @@ -57,8 +60,9 @@ for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; i++) { if ((dev = host->getDevice(i)) != NULL) { - if(host->enumerate(dev, this)) + if(host->enumerate(dev, this)) { break; + } if (mouse_device_found) { { /* As this is done in a specific thread @@ -66,8 +70,9 @@ * disconnect in usb process during the device registering */ USBHost::Lock Lock(host); int_in = dev->getEndpoint(mouse_intf, INTERRUPT_ENDPOINT, IN); - if (!int_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); @@ -81,10 +86,12 @@ } 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)) + if ((ret==USB_TYPE_OK) || (ret ==USB_TYPE_PROCESSING)) { dev_connected = true; - if (ret == USB_TYPE_FREE) + } + if (ret == USB_TYPE_FREE) { dev_connected = false; + } return true; } } @@ -93,7 +100,8 @@ return false; } -void USBHostMouse::rxHandler() { +void USBHostMouse::rxHandler() +{ int len_listen = int_in->getLengthTransferred(); if (len_listen !=0) { @@ -130,8 +138,9 @@ len_listen = sizeof(report); } - if (dev) + if (dev) { host->interruptRead(dev, int_in, report, len_listen, false); + } } /*virtual*/ void USBHostMouse::setVidPid(uint16_t vid, uint16_t pid) @@ -142,9 +151,9 @@ /*virtual*/ bool USBHostMouse::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 { if ((mouse_intf == -1) && - (intf_class == HID_CLASS) && - (intf_subclass == 0x01) && - (intf_protocol == 0x02)) { + (intf_class == HID_CLASS) && + (intf_subclass == 0x01) && + (intf_protocol == 0x02)) { mouse_intf = intf_nb; return true; }