50 Notify(PSTR(
"\r\nXBOXUSB Init"), 0x80);
55 Notify(PSTR(
"\r\nAddress in use"), 0x80);
65 Notify(PSTR(
"\r\nAddress not found"), 0x80);
72 Notify(PSTR(
"\r\nepinfo is null"), 0x80);
97 goto FailUnknownDevice;
100 Notify(PSTR(
"\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80);
102 goto FailUnknownDevice;
104 #ifdef DEBUG_USB_HOST
105 Notify(PSTR(
"\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
107 goto FailUnknownDevice;
109 goto FailUnknownDevice;
126 #ifdef DEBUG_USB_HOST
127 Notify(PSTR(
"\r\nsetAddr: "), 0x80);
128 D_PrintHex<uint8_t > (rcode, 0x80);
133 Notify(PSTR(
"\r\nAddr: "), 0x80);
134 D_PrintHex<uint8_t > (
bAddress, 0x80);
150 goto FailSetDevTblEntry;
172 goto FailSetDevTblEntry;
178 goto FailSetConfDescr;
180 #ifdef DEBUG_USB_HOST
181 Notify(PSTR(
"\r\nXbox 360 Controller Connected\r\n"), 0x80);
190 #ifdef DEBUG_USB_HOST
196 #ifdef DEBUG_USB_HOST
202 #ifdef DEBUG_USB_HOST
208 #ifdef DEBUG_USB_HOST
214 #ifdef DEBUG_USB_HOST
215 Notify(PSTR(
"\r\nXbox 360 Init Failed, error code: "), 0x80);
243 void XBOXUSB::readReport() {
246 if(readBuf[0] != 0x00 || readBuf[1] != 0x14) {
250 ButtonState = (uint32_t)(readBuf[5] | ((uint16_t)readBuf[4] << 8) | ((uint32_t)readBuf[3] << 16) | ((uint32_t)readBuf[2] << 24));
252 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]);
253 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]);
254 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
255 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
260 if(ButtonState != OldButtonState) {
261 ButtonClickState = (ButtonState >> 16) & ((~OldButtonState) >> 16);
262 if(((uint8_t)OldButtonState) == 0 && ((uint8_t)ButtonState) != 0)
264 if((uint8_t)(OldButtonState >> 8) == 0 && (uint8_t)(ButtonState >> 8) != 0)
266 OldButtonState = ButtonState;
270 void XBOXUSB::printReport() {
275 D_PrintHex<uint8_t > (readBuf[i], 0x80);
278 Notify(PSTR(
"\r\n"), 0x80);
284 return (uint8_t)(ButtonState >> 8);
286 return (uint8_t)ButtonState;
287 return (
bool)(ButtonState & ((uint32_t)pgm_read_word(&
XBOX_BUTTONS[(uint8_t)b]) << 16));
304 uint16_t button = pgm_read_word(&
XBOX_BUTTONS[(uint8_t)b]);
305 bool click = (ButtonClickState & button);
306 ButtonClickState &= ~button;
315 void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) {
317 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
325 XboxCommand(writeBuf, 3);
347 writeBuf[3] = lValue;
348 writeBuf[4] = rValue;
353 XboxCommand(writeBuf, 8);
356 void XBOXUSB::onInit() {
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID
#define USB_ERROR_EPINFO_IS_NULL
#define XBOX_WIRELESS_RECEIVER_PID
#define XBOX_REPORT_BUFFER_SIZE
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
int16_t getAnalogHat(AnalogHatEnum a)
void setLedBlink(LEDEnum l)
#define NotifyFailGetDevDescr(...)
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
#define HID_REQUEST_SET_REPORT
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
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data)
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
const uint8_t XBOX_LEDS[]
bool getButtonClick(ButtonEnum b)
#define XBOX_MAX_ENDPOINTS
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
virtual uint8_t Release()
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