A fully-Android-compatible two joysticks USB driver for LPC1768. The joysticks have 1 hat, 6 buttons, and there are 1P, 2P buttons.
Fork of app-board-Joystick by
Diff: usbdevice.cpp
- Revision:
- 3:f1a8ec4659f8
- Parent:
- 1:76c47d2ba442
diff -r 84ea6e2fb4b6 -r f1a8ec4659f8 usbdevice.cpp --- a/usbdevice.cpp Sat Dec 17 13:13:59 2016 +0000 +++ b/usbdevice.cpp Sat Dec 17 15:10:12 2016 +0000 @@ -2,6 +2,8 @@ /* Generic USB device */ /* Copyright (c) Phil Wright 2008 */ +/* Modified by yours truly. */ + #include "mbed.h" #include "usbdevice.h" @@ -94,9 +96,9 @@ packet->bmRequestType.Type = (data[0] & 0x60) >> 5; packet->bmRequestType.Recipient = data[0] & 0x1f; packet->bRequest = data[1]; - packet->wValue = (data[2] | (unsigned short)data[3] << 8); - packet->wIndex = (data[4] | (unsigned short)data[5] << 8); - packet->wLength = (data[6] | (unsigned short)data[7] << 8); + packet->wValue = (data[2] | (unsigned short) data[3] << 8); + packet->wIndex = (data[4] | (unsigned short) data[5] << 8); + packet->wLength = (data[6] | (unsigned short) data[7] << 8); } bool usbdevice::controlSetup() @@ -123,7 +125,7 @@ /* Check transfer size and direction */ if (transfer.setup.wLength > 0) { - if (transfer.setup.bmRequestType.dataTransferDirection==DEVICE_TO_HOST) + if (transfer.setup.bmRequestType.dataTransferDirection == DEVICE_TO_HOST) { /* IN data stage is required */ if (transfer.direction != DEVICE_TO_HOST)