Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: x4180_Tank Totaleprogramma Handmatig Totaleprogramma1
Fork of USBHostXpad by
Diff: USBHostXpad.cpp
- Revision:
- 2:2749f4e649db
- Parent:
- 1:5bb153989f33
- Child:
- 3:53ce7778a155
diff -r 5bb153989f33 -r 2749f4e649db USBHostXpad.cpp
--- a/USBHostXpad.cpp Wed Dec 11 04:11:04 2013 +0000
+++ b/USBHostXpad.cpp Wed Dec 11 05:03:05 2013 +0000
@@ -69,7 +69,7 @@
host->interruptRead(dev, int_in, report, int_in->getSize(), false);
Thread::wait(100);
- led(XPAD_LED_OFF);
+ led(LED_OFF);
dev_connected = true;
return true;
}
@@ -97,7 +97,7 @@
} else
if (report[0] == 0x00 && report[1] == 0x0f) {
// On connection
- led(XPAD_LED1_ON);
+ led(LED1_ON);
send(0x00, 0x00, 0x00, 0x40);
goto exit;
} else
@@ -167,7 +167,10 @@
void USBHostXpad::restart ()
{
- send(0x08, 0x00, 0x0f, 0xc0);
+ if (send(0x08, 0x00, 0x0f, 0xc0) == false) {
+ init();
+ return;
+ }
send(0x08, 0x00, 0x0f, 0xc0);
send(0x08, 0x00, 0x0f, 0xc0);
send(0x08, 0x00, 0x0f, 0xc0);
@@ -190,7 +193,26 @@
return true;
}
-bool USBHostXpad::led(int cmd)
+int USBHostXpad::read (TYPE type) {
+ switch (type) {
+ case XPAD_STICK_LX:
+ return stick_lx;
+ case XPAD_STICK_LY:
+ return stick_ly;
+ case XPAD_STICK_RX:
+ return stick_rx;
+ case XPAD_STICK_RY:
+ return stick_ry;
+ case XPAD_TRIGGER_L:
+ return trigger_l;
+ case XPAD_TRIGGER_R:
+ return trigger_r;
+ default:
+ return (buttons & type) ? 1 : 0;
+ }
+}
+
+bool USBHostXpad::led(LED cmd)
{
unsigned char odata[32];
memset(odata, 0, sizeof(odata));
