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);
286 return (uint8_t)(ButtonState >> 8);
288 return (uint8_t)ButtonState;
308 bool click = (ButtonClickState & button);
309 ButtonClickState &= ~button;
318 void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) {
320 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
328 XboxCommand(writeBuf, 3);
350 writeBuf[3] = lValue;
351 writeBuf[4] = rValue;
356 XboxCommand(writeBuf, 8);
359 void XBOXUSB::onInit() {
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
#define USB_ERROR_EPINFO_IS_NULL
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define XBOX_CONTROL_PIPE
#define XBOX_MAX_ENDPOINTS
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID
#define XBOX_WIRELESS_PID
#define XBOX_WIRELESS_RECEIVER_PID
#define JOYTECH_WIRED_PID
#define GAMESTOP_WIRED_PID
#define MADCATZ_WIRED_PID
#define AFTERGLOW_WIRED_PID
#define XBOX_REPORT_BUFFER_SIZE
#define USB_NAK_MAX_POWER
virtual void FreeAddress(uint8_t addr)=0
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
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)
AddressPool & GetAddressPool()
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
void setLedMode(LEDModeEnum lm)
uint8_t getButtonPress(ButtonEnum b)
void setLedRaw(uint8_t value)
void setLedBlink(LEDEnum l)
bool getButtonClick(ButtonEnum b)
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
int16_t getAnalogHat(AnalogHatEnum a)
EpInfo epInfo[XBOX_MAX_ENDPOINTS]
void setRumbleOn(uint8_t lValue, uint8_t rValue)
constexpr int8_t ButtonIndex(ButtonEnum key)
#define NotifyFailSetConfDescr(...)
#define NotifyFailUnknownDevice(...)
#define NotifyFailSetDevTblEntry(...)
#define NotifyFailGetDevDescr(...)
#define USB_TRANSFER_TYPE_INTERRUPT
#define HID_REQUEST_SET_REPORT
#define pgm_read_byte(addr)
#define pgm_read_word(addr)
const uint8_t XBOX_LEDS[]
const uint16_t XBOX_BUTTONS[]
int8_t getButtonIndexXbox(ButtonEnum b)