116 goto FailGetDevDescr;
119 PID = udd->idProduct;
122 goto FailUnknownDevice;
139 #ifdef DEBUG_USB_HOST 141 D_PrintHex<uint8_t > (rcode, 0x80);
147 D_PrintHex<uint8_t > (
bAddress, 0x80);
163 goto FailSetDevTblEntry;
185 goto FailSetDevTblEntry;
191 goto FailSetConfDescr;
193 #ifdef DEBUG_USB_HOST 194 Notify(
PSTR(
"\r\nXbox Controller Connected\r\n"), 0x80);
204 #ifdef DEBUG_USB_HOST 210 #ifdef DEBUG_USB_HOST 216 #ifdef DEBUG_USB_HOST 222 #ifdef DEBUG_USB_HOST 228 #ifdef DEBUG_USB_HOST 229 Notify(
PSTR(
"\r\nXbox Init Failed, error code: "), 0x80);
252 printReport(BUFFER_SIZE);
257 void XBOXOLD::readReport() {
258 ButtonState = readBuf[2];
260 for(uint8_t i = 0; i <
sizeof (buttonValues); i++)
261 buttonValues[i] = readBuf[i + 4];
263 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[12] << 8) | readBuf[13]);
264 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[14] << 8) | readBuf[15]);
265 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[16] << 8) | readBuf[17]);
266 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[18] << 8) | readBuf[19]);
271 if(ButtonState != OldButtonState || memcmp(buttonValues, oldButtonValues,
sizeof (buttonValues)) != 0) {
272 ButtonClickState = ButtonState & ~OldButtonState;
273 OldButtonState = ButtonState;
275 for(uint8_t i = 0; i <
sizeof (buttonValues); i++) {
276 if(oldButtonValues[i] == 0 && buttonValues[i] != 0)
277 buttonClicked[i] =
true;
278 oldButtonValues[i] = buttonValues[i];
283 void XBOXOLD::printReport(uint16_t length __attribute__((unused))) {
287 for(uint8_t i = 0; i < length; i++) {
288 D_PrintHex<uint8_t > (readBuf[i], 0x80);
297 if(b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1)
298 return buttonValues[button];
299 return (ButtonState & button);
304 if(b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1) {
305 if(buttonClicked[button]) {
306 buttonClicked[button] =
false;
312 bool click = (ButtonClickState & button);
313 ButtonClickState &= ~button;
322 void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) {
324 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
333 writeBuf[3] = rValue;
335 writeBuf[5] = lValue;
337 XboxCommand(writeBuf, 6);
#define USB_ERROR_EPINFO_IS_NULL
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
#define USB_TRANSFER_TYPE_INTERRUPT
#define pgm_read_byte(addr)
void setRumbleOn(uint8_t lValue, uint8_t rValue)
#define NotifyFailGetDevDescr(...)
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
EpInfo epInfo[XBOX_MAX_ENDPOINTS]
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
const uint8_t XBOXOLD_BUTTONS[]
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define NotifyFailUnknownDevice(...)
#define USB_NAK_MAX_POWER
int16_t getAnalogHat(AnalogHatEnum a)
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define XBOX_MAX_ENDPOINTS
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval=0)
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
AddressPool & GetAddressPool()
bool getButtonClick(ButtonEnum b)
uint8_t getButtonPress(ButtonEnum b)
#define XBOX_CONTROL_PIPE
#define HID_REQUEST_SET_REPORT
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(...)