Xbox 360 Wireless Controller for Windows library. sample: http://mbed.org/users/okini3939/code/USBHostXpad_HelloWorld/

Dependents:   x4180_Tank Totaleprogramma Handmatig Totaleprogramma1

Fork of USBHostXpad by Suga koubou

Revision:
2:2749f4e649db
Parent:
1:5bb153989f33
Child:
3:53ce7778a155
--- a/USBHostXpad.h	Wed Dec 11 04:11:04 2013 +0000
+++ b/USBHostXpad.h	Wed Dec 11 05:03:05 2013 +0000
@@ -15,41 +15,50 @@
 
 #include "USBHost.h"
 
-#define XPAD_HAT_UP     0x0001
-#define XPAD_HAT_DOWN   0x0002
-#define XPAD_HAT_LEFT   0x0004
-#define XPAD_HAT_RIGHT  0x0008
-#define XPAD_START      0x0010
-#define XPAD_BACK       0x0020
-#define XPAD_STICK_L    0x0040
-#define XPAD_STICK_R    0x0080
-#define XPAD_PAD_LB     0x0100
-#define XPAD_PAD_RB     0x0200
-#define XPAD_XLOGO      0x0400
-#define XPAD_PAD_A      0x1000
-#define XPAD_PAD_B      0x2000
-#define XPAD_PAD_X      0x4000
-#define XPAD_PAD_Y      0x8000
-
-#define XPAD_LED_OFF    0x00
-#define XPAD_LED_BLINK  0x01
-#define XPAD_LED1_FLASH 0x02
-#define XPAD_LED2_FLASH 0x03
-#define XPAD_LED3_FLASH 0x04
-#define XPAD_LED4_FLASH 0x05
-#define XPAD_LED1_ON    0x06
-#define XPAD_LED2_ON    0x07
-#define XPAD_LED3_ON    0x08
-#define XPAD_LED4_ON    0x09
-#define XPAD_LED_ROTATE 0x0a
-#define XPAD_LED_ALTERNATE 0x0d
-
-
 /** 
  * A class to communicate a USB flash disk
  */
 class USBHostXpad : public IUSBEnumerator {
 public:
+    enum TYPE {
+        XPAD_HAT_UP    = 0x0001,
+        XPAD_HAT_DOWN  = 0x0002,
+        XPAD_HAT_LEFT  = 0x0004,
+        XPAD_HAT_RIGHT = 0x0008,
+        XPAD_START     = 0x0010,
+        XPAD_BACK      = 0x0020,
+        XPAD_STICK_L   = 0x0040,
+        XPAD_STICK_R   = 0x0080,
+        XPAD_PAD_LB    = 0x0100,
+        XPAD_PAD_RB    = 0x0200,
+        XPAD_XLOGO     = 0x0400,
+        XPAD_PAD_A     = 0x1000,
+        XPAD_PAD_B     = 0x2000,
+        XPAD_PAD_X     = 0x4000,
+        XPAD_PAD_Y     = 0x8000,
+        XPAD_STICK_LX  = 0x10000,
+        XPAD_STICK_LY  = 0x10001,
+        XPAD_STICK_RX  = 0x10002,
+        XPAD_STICK_RY  = 0x10003,
+        XPAD_TRIGGER_L = 0x10004,
+        XPAD_TRIGGER_R = 0x10005,
+    };
+
+    enum LED {
+        LED_OFF    = 0x00,
+        LED_BLINK  = 0x01,
+        LED1_FLASH = 0x02,
+        LED2_FLASH = 0x03,
+        LED3_FLASH = 0x04,
+        LED4_FLASH = 0x05,
+        LED1_ON    = 0x06,
+        LED2_ON    = 0x07,
+        LED3_ON    = 0x08,
+        LED4_ON    = 0x09,
+        LED_ROTATE = 0x0a,
+        LED_ALTERNATE = 0x0d,
+    };
+
     /**
     * Constructor
     *
@@ -82,8 +91,9 @@
         }
     }
 
-    bool led(int cmd);
-    bool rumble(uint8_t large, uint8_t small);
+    int read (TYPE type);
+    bool led (LED cmd);
+    bool rumble (uint8_t large, uint8_t small);
 
     void restart ();