modified to compile for me
Fork of USBHostXpad by
USBHostXpad.h
- Committer:
- okini3939
- Date:
- 2013-12-11
- Revision:
- 2:2749f4e649db
- Parent:
- 1:5bb153989f33
- Child:
- 3:53ce7778a155
File content as of revision 2:2749f4e649db:
/* * Xbox 360 Wireless Controller for Windows library * for mbed USBHost library * Copyright (c) 2013 Hiroshi Suga * * VID=0x045e PID=0x0719 */ #ifndef USBHostXpad_H #define USBHostXpad_H #include "USBHostConf.h" #if 1 or USBHOST_XPAD #include "USBHost.h" /** * 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 * * @param rootdir mount name */ USBHostXpad(); /** * Check if a MSD device is connected * * @return true if a MSD device is connected */ bool connected(); /** * Try to connect to a MSD device * * @return true if connection was successful */ bool connect(); /** * Attach a callback called when a mouse event is received * * @param ptr function pointer */ inline void attachEvent(void (*ptr)(int buttons, int stick_lx, int stick_ly, int stick_rx, int stick_ry, int trigger_l, int trigger_r)) { if (ptr != NULL) { onUpdate = ptr; } } int read (TYPE type); bool led (LED cmd); bool rumble (uint8_t large, uint8_t small); void restart (); protected: //From IUSBEnumerator virtual void setVidPid(uint16_t vid, uint16_t pid); virtual bool 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 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used private: USBHost * host; USBDeviceConnected * dev; bool dev_connected; USBEndpoint * int_in; USBEndpoint * int_out; uint8_t nb_ep; int xpad_intf; bool xpad_device_found; uint8_t report[32]; uint32_t buttons; int16_t stick_lx, stick_ly, stick_rx, stick_ry; uint8_t trigger_l, trigger_r; void rxHandler(); 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); }; #endif #endif