73 Notify(PSTR(
"\r\nXBOXUSB Init"), 0x80);
78 Notify(PSTR(
"\r\nAddress in use"), 0x80);
88 Notify(PSTR(
"\r\nAddress not found"), 0x80);
95 Notify(PSTR(
"\r\nepinfo is null"), 0x80);
114 goto FailGetDevDescr;
120 goto FailUnknownDevice;
137 #ifdef DEBUG_USB_HOST
138 Notify(PSTR(
"\r\nsetAddr: "), 0x80);
139 D_PrintHex<uint8_t > (rcode, 0x80);
144 Notify(PSTR(
"\r\nAddr: "), 0x80);
145 D_PrintHex<uint8_t > (
bAddress, 0x80);
161 goto FailSetDevTblEntry;
183 goto FailSetDevTblEntry;
189 goto FailSetConfDescr;
191 #ifdef DEBUG_USB_HOST
192 Notify(PSTR(
"\r\nXbox Controller Connected\r\n"), 0x80);
202 #ifdef DEBUG_USB_HOST
208 #ifdef DEBUG_USB_HOST
214 #ifdef DEBUG_USB_HOST
219 #ifdef DEBUG_USB_HOST
225 #ifdef DEBUG_USB_HOST
226 Notify(PSTR(
"\r\nXbox Init Failed, error code: "), 0x80);
249 printReport(BUFFER_SIZE);
254 void XBOXOLD::readReport() {
255 ButtonState = readBuf[2];
257 for (uint8_t i = 0; i <
sizeof(buttonValues); i++)
258 buttonValues[i] = readBuf[i + 4];
260 hatValue[
LeftHatX] = (int16_t)(((uint16_t)readBuf[12] << 8) | readBuf[13]);
261 hatValue[
LeftHatY] = (int16_t)(((uint16_t)readBuf[14] << 8) | readBuf[15]);
262 hatValue[
RightHatX] = (int16_t)(((uint16_t)readBuf[16] << 8) | readBuf[17]);
263 hatValue[
RightHatY] = (int16_t)(((uint16_t)readBuf[18] << 8) | readBuf[19]);
268 if (ButtonState != OldButtonState || memcmp(buttonValues, oldButtonValues,
sizeof(buttonValues)) != 0) {
269 ButtonClickState = ButtonState & ~OldButtonState;
270 OldButtonState = ButtonState;
272 for (uint8_t i = 0; i <
sizeof(buttonValues); i++) {
273 if (oldButtonValues[i] == 0 && buttonValues[i] != 0)
274 buttonClicked[i] =
true;
275 oldButtonValues[i] = buttonValues[i];
280 void XBOXOLD::printReport(uint16_t length) {
284 for (uint8_t i = 0; i < length; i++) {
285 D_PrintHex<uint8_t > (readBuf[i], 0x80);
288 Notify(PSTR(
"\r\n"), 0x80);
294 if (b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1)
295 return buttonValues[button];
296 return (ButtonState & button);
301 if (b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1) {
302 if (buttonClicked[button]) {
303 buttonClicked[button] =
false;
309 bool click = (ButtonClickState & button);
310 ButtonClickState &= ~button;
319 void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) {
321 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
330 writeBuf[3] = rValue;
332 writeBuf[5] = lValue;
334 XboxCommand(writeBuf, 6);
#define USB_ERROR_EPINFO_IS_NULL
virtual uint8_t Release()
const uint8_t XBOXOLDBUTTONS[]
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
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
#define NotifyFailUnknownDevice(...)
#define USB_NAK_MAX_POWER
#define HID_REQUEST_SET_REPORT
uint8_t getButtonPress(Button b)
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
int16_t getAnalogHat(AnalogHat a)
#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
bool getButtonClick(Button b)
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
AddressPool & GetAddressPool()
#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(...)