modified to compile for me
Fork of USBHostXpad by
Diff: USBHostXpad.h
- Revision:
- 3:53ce7778a155
- Parent:
- 2:2749f4e649db
- Child:
- 6:954ecd99709c
--- a/USBHostXpad.h Wed Dec 11 05:03:05 2013 +0000 +++ b/USBHostXpad.h Fri Dec 13 07:36:09 2013 +0000 @@ -20,7 +20,7 @@ */ class USBHostXpad : public IUSBEnumerator { public: - enum TYPE { + enum PAD { XPAD_HAT_UP = 0x0001, XPAD_HAT_DOWN = 0x0002, XPAD_HAT_LEFT = 0x0004, @@ -36,12 +36,14 @@ 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, + XPAD_BUTTONS = 0x10000, + XPAD_STICK_LX, + XPAD_STICK_LY, + XPAD_STICK_RX, + XPAD_STICK_RY, + XPAD_TRIGGER_L, + XPAD_TRIGGER_R, + XPAD_BATTERY, }; enum LED { @@ -59,6 +61,13 @@ LED_ALTERNATE = 0x0d, }; + enum TYPE { + TYPE_UNKNOWN, + TYPE_XBOX, + TYPE_XBOX360, + TYPE_XBOX360W, + }; + /** * Constructor * @@ -91,11 +100,12 @@ } } - int read (TYPE type); + int read (PAD pad); bool led (LED cmd); bool rumble (uint8_t large, uint8_t small); - void restart (); + bool restart (); + bool stop(); protected: //From IUSBEnumerator @@ -106,7 +116,9 @@ private: USBHost * host; USBDeviceConnected * dev; - bool dev_connected; + volatile bool dev_connected; + TYPE dev_type; + volatile bool dev_started; USBEndpoint * int_in; USBEndpoint * int_out; @@ -118,11 +130,13 @@ uint32_t buttons; int16_t stick_lx, stick_ly, stick_rx, stick_ry; uint8_t trigger_l, trigger_r; + uint8_t battery; void rxHandler(); + void parseMessage(); void (*onUpdate)(int buttons, int stick_lx, int stick_ly, int stick_rx, int stick_ry, int trigger_l, int trigger_r); void init(); - bool send(int val1, int val2, int val3, int val4); + bool start(); };