49 Notify(PSTR(
"\r\nXBOXUSB Init"), 0x80);
54 Notify(PSTR(
"\r\nAddress in use"), 0x80);
64 Notify(PSTR(
"\r\nAddress not found"), 0x80);
71 Notify(PSTR(
"\r\nepinfo is null"), 0x80);
96 goto FailUnknownDevice;
99 Notify(PSTR(
"\r\nYou have plugged in a wireless Xbox 360 controller - it doesn't support USB communication"), 0x80);
101 goto FailUnknownDevice;
103 #ifdef DEBUG_USB_HOST
104 Notify(PSTR(
"\r\nThis library only supports Xbox 360 controllers via USB"), 0x80);
106 goto FailUnknownDevice;
108 goto FailUnknownDevice;
125 #ifdef DEBUG_USB_HOST
126 Notify(PSTR(
"\r\nsetAddr: "), 0x80);
127 D_PrintHex<uint8_t > (rcode, 0x80);
132 Notify(PSTR(
"\r\nAddr: "), 0x80);
133 D_PrintHex<uint8_t > (
bAddress, 0x80);
149 goto FailSetDevTblEntry;
171 goto FailSetDevTblEntry;
177 goto FailSetConfDescr;
179 #ifdef DEBUG_USB_HOST
180 Notify(PSTR(
"\r\nXbox 360 Controller Connected\r\n"), 0x80);
189 #ifdef DEBUG_USB_HOST
195 #ifdef DEBUG_USB_HOST
201 #ifdef DEBUG_USB_HOST
206 #ifdef DEBUG_USB_HOST
212 #ifdef DEBUG_USB_HOST
213 Notify(PSTR(
"\r\nXbox 360 Init Failed, error code: "), 0x80);
241 void XBOXUSB::readReport() {
244 if (readBuf[0] != 0x00 || readBuf[1] != 0x14) {
248 ButtonState = (uint32_t)(readBuf[5] | ((uint16_t)readBuf[4] << 8) | ((uint32_t)readBuf[3] << 16) | ((uint32_t)readBuf[2] << 24));
250 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]);
251 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]);
252 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
253 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
258 if (ButtonState != OldButtonState) {
259 ButtonClickState = (ButtonState >> 16) & ((~OldButtonState) >> 16);
260 if (((uint8_t)OldButtonState) == 0 && ((uint8_t)ButtonState) != 0)
262 if ((uint8_t)(OldButtonState >> 8) == 0 && (uint8_t)(ButtonState >> 8) != 0)
264 OldButtonState = ButtonState;
268 void XBOXUSB::printReport() {
273 D_PrintHex<uint8_t > (readBuf[i], 0x80);
276 Notify(PSTR(
"\r\n"), 0x80);
282 return (uint8_t)(ButtonState >> 8);
284 return (uint8_t)ButtonState;
285 return (
bool)(ButtonState & ((uint32_t)pgm_read_word(&
XBOXBUTTONS[(uint8_t)b]) << 16));
295 }
else if (b ==
R2) {
302 uint16_t button = pgm_read_word(&
XBOXBUTTONS[(uint8_t)b]);
303 bool click = (ButtonClickState & button);
304 ButtonClickState &= ~button;
313 void XBOXUSB::XboxCommand(uint8_t* data, uint16_t nbytes) {
315 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
323 XboxCommand(writeBuf, 3);
343 writeBuf[3] = lValue;
344 writeBuf[4] = rValue;
349 XboxCommand(writeBuf, 8);
352 void XBOXUSB::onInit() {
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID
#define USB_ERROR_EPINFO_IS_NULL
#define XBOX_WIRELESS_RECEIVER_PID
void setLedMode(LEDMode lm)
#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)
uint8_t getButtonPress(Button b)
#define NotifyFailGetDevDescr(...)
const uint16_t XBOXBUTTONS[]
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
bool getButtonClick(Button b)
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
int16_t getAnalogHat(AnalogHat a)
#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
#define XBOX_MAX_ENDPOINTS
void setLedRaw(uint8_t value)
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
AddressPool & GetAddressPool()
#define XBOX_CONTROL_PIPE
virtual uint8_t Release()
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