98 goto FailUnknownDevice;
100 #ifdef DEBUG_USB_HOST 101 Notify(
PSTR(
"\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80);
103 goto FailUnknownDevice;
105 #ifdef DEBUG_USB_HOST 106 Notify(
PSTR(
"\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
108 goto FailUnknownDevice;
110 goto FailUnknownDevice;
127 #ifdef DEBUG_USB_HOST 129 D_PrintHex<uint8_t > (rcode, 0x80);
135 D_PrintHex<uint8_t > (
bAddress, 0x80);
151 goto FailSetDevTblEntry;
173 goto FailSetDevTblEntry;
179 goto FailSetConfDescr;
181 #ifdef DEBUG_USB_HOST 182 Notify(
PSTR(
"\r\nXbox 360 Controller Connected\r\n"), 0x80);
191 #ifdef DEBUG_USB_HOST 197 #ifdef DEBUG_USB_HOST 203 #ifdef DEBUG_USB_HOST 209 #ifdef DEBUG_USB_HOST 215 #ifdef DEBUG_USB_HOST 216 Notify(
PSTR(
"\r\nXbox 360 Init Failed, error code: "), 0x80);
244 void XBOXUSB::readReport() {
247 if(readBuf[0] != 0x00 || readBuf[1] != 0x14) {
251 ButtonState = (uint32_t)(readBuf[5] | ((uint16_t)readBuf[4] << 8) | ((uint32_t)readBuf[3] << 16) | ((uint32_t)readBuf[2] << 24));
253 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]);
254 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]);
255 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
256 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
261 if(ButtonState != OldButtonState) {
262 ButtonClickState = (ButtonState >> 16) & ((~OldButtonState) >> 16);
263 if(((uint8_t)OldButtonState) == 0 && ((uint8_t)ButtonState) != 0)
265 if((uint8_t)(OldButtonState >> 8) == 0 && (uint8_t)(ButtonState >> 8) != 0)
267 OldButtonState = ButtonState;
271 void XBOXUSB::printReport() {
276 D_PrintHex<uint8_t > (readBuf[i], 0x80);
285 return (uint8_t)(ButtonState >> 8);
287 return (uint8_t)ButtonState;
306 bool click = (ButtonClickState & button);
307 ButtonClickState &= ~button;
316 void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) {
318 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
326 XboxCommand(writeBuf, 3);
348 writeBuf[3] = lValue;
349 writeBuf[4] = rValue;
354 XboxCommand(writeBuf, 8);
357 void XBOXUSB::onInit() {
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID
#define USB_ERROR_EPINFO_IS_NULL
#define XBOX_WIRELESS_RECEIVER_PID
#define pgm_read_word(addr)
#define JOYTECH_WIRED_PID
#define XBOX_REPORT_BUFFER_SIZE
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define USB_TRANSFER_TYPE_INTERRUPT
int16_t getAnalogHat(AnalogHatEnum a)
void setLedBlink(LEDEnum l)
#define pgm_read_byte(addr)
#define NotifyFailGetDevDescr(...)
#define AFTERGLOW_WIRED_PID
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
virtual void FreeAddress(uint8_t addr)=0
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi, uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p)
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define NotifyFailUnknownDevice(...)
#define USB_NAK_MAX_POWER
uint8_t getButtonPress(ButtonEnum b)
#define XBOX_WIRELESS_PID
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
void setRumbleOn(uint8_t lValue, uint8_t rValue)
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
const uint8_t XBOX_LEDS[]
bool getButtonClick(ButtonEnum b)
#define XBOX_MAX_ENDPOINTS
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
void setLedRaw(uint8_t value)
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
void setLedMode(LEDModeEnum lm)
#define MADCATZ_WIRED_PID
AddressPool & GetAddressPool()
#define XBOX_CONTROL_PIPE
#define HID_REQUEST_SET_REPORT
const uint16_t XBOX_BUTTONS[]
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
#define NotifyFailSetConfDescr(...)
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
#define NotifyFailSetDevTblEntry(...)
EpInfo epInfo[XBOX_MAX_ENDPOINTS]
#define GAMESTOP_WIRED_PID