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);
293 if (b ==
A || b ==
B || b ==
X || b ==
Y || b ==
BLACK || b ==
WHITE || b ==
L1 || b ==
R1)
295 return (ButtonState & pgm_read_byte(&
XBOXOLDBUTTONS[(uint8_t)b]));
300 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;
304 return buttonClicked[button];
308 bool click = (ButtonClickState & button);
309 ButtonClickState &= ~button;
318 void XBOXOLD::XboxCommand(uint8_t* data, uint16_t nbytes) {
320 pUsb->
ctrlReq(
bAddress,
epInfo[
XBOX_CONTROL_PIPE].epAddr,
bmREQ_HID_OUT,
HID_REQUEST_SET_REPORT, 0x00, 0x02, 0x00, nbytes, nbytes, data, NULL);
329 writeBuf[3] = rValue;
331 writeBuf[5] = lValue;
333 XboxCommand(writeBuf, 6);