74 Notify(PSTR(
"\r\nXBOXUSB Init"), 0x80);
79 Notify(PSTR(
"\r\nAddress in use"), 0x80);
89 Notify(PSTR(
"\r\nAddress not found"), 0x80);
96 Notify(PSTR(
"\r\nepinfo is null"), 0x80);
115 goto FailGetDevDescr;
118 PID = udd->idProduct;
121 goto FailUnknownDevice;
138 #ifdef DEBUG_USB_HOST
139 Notify(PSTR(
"\r\nsetAddr: "), 0x80);
140 D_PrintHex<uint8_t > (rcode, 0x80);
145 Notify(PSTR(
"\r\nAddr: "), 0x80);
146 D_PrintHex<uint8_t > (
bAddress, 0x80);
162 goto FailSetDevTblEntry;
184 goto FailSetDevTblEntry;
190 goto FailSetConfDescr;
192 #ifdef DEBUG_USB_HOST
193 Notify(PSTR(
"\r\nXbox Controller Connected\r\n"), 0x80);
203 #ifdef DEBUG_USB_HOST
209 #ifdef DEBUG_USB_HOST
215 #ifdef DEBUG_USB_HOST
221 #ifdef DEBUG_USB_HOST
227 #ifdef DEBUG_USB_HOST
228 Notify(PSTR(
"\r\nXbox Init Failed, error code: "), 0x80);
251 printReport(BUFFER_SIZE);
256 void XBOXOLD::readReport() {
257 ButtonState = readBuf[2];
259 for(uint8_t i = 0; i <
sizeof (buttonValues); i++)
260 buttonValues[i] = readBuf[i + 4];
262 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[12] << 8) | readBuf[13]);
263 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[14] << 8) | readBuf[15]);
264 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[16] << 8) | readBuf[17]);
265 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[18] << 8) | readBuf[19]);
270 if(ButtonState != OldButtonState || memcmp(buttonValues, oldButtonValues,
sizeof (buttonValues)) != 0) {
271 ButtonClickState = ButtonState & ~OldButtonState;
272 OldButtonState = ButtonState;
274 for(uint8_t i = 0; i <
sizeof (buttonValues); i++) {
275 if(oldButtonValues[i] == 0 && buttonValues[i] != 0)
276 buttonClicked[i] =
true;
277 oldButtonValues[i] = buttonValues[i];
282 void XBOXOLD::printReport(uint16_t length) {
286 for(uint8_t i = 0; i < length; i++) {
287 D_PrintHex<uint8_t > (readBuf[i], 0x80);
290 Notify(PSTR(
"\r\n"), 0x80);
296 if(b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1)
297 return buttonValues[button];
298 return (ButtonState & button);
303 if(b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1) {
304 if(buttonClicked[button]) {
305 buttonClicked[button] =
false;
311 bool click = (ButtonClickState & button);
312 ButtonClickState &= ~button;
321 void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) {
323 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
332 writeBuf[3] = rValue;
334 writeBuf[5] = lValue;
336 XboxCommand(writeBuf, 6);
#define USB_ERROR_EPINFO_IS_NULL
virtual uint8_t Release()
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
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)
#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
#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
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
#define XBOX_MAX_ENDPOINTS
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
AddressPool & GetAddressPool()
bool getButtonClick(ButtonEnum b)
uint8_t getButtonPress(ButtonEnum b)
#define XBOX_CONTROL_PIPE
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(...)