USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
XBOXRECV.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
2 
3  This software may be distributed and modified under the terms of the GNU
4  General Public License version 2 (GPL2) as published by the Free Software
5  Foundation and appearing in the file GPL2.TXT included in the packaging of
6  this file. Please note that GPL2 Section 2[b] requires that all works based
7  on this software must also be made publicly available under the terms of
8  the GPL2 ("Copyleft").
9 
10  Contact information
11  -------------------
12 
13  Kristian Lauszus, TKJ Electronics
14  Web : http://www.tkjelectronics.com
15  e-mail : kristianl@tkjelectronics.com
16 
17  getBatteryLevel and checkStatus functions made by timstamp.co.uk found using BusHound from Perisoft.net
18  */
19 
20 #include "XBOXRECV.h"
21 // To enable serial debugging see "settings.h"
22 //#define EXTRADEBUG // Uncomment to get even more debugging data
23 //#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
24 
26 pUsb(p), // pointer to USB class instance - mandatory
27 bAddress(0), // device address - mandatory
28 bPollEnable(false) { // don't start polling before dongle is connected
29  for (uint8_t i = 0; i < XBOX_MAX_ENDPOINTS; i++) {
30  epInfo[i].epAddr = 0;
31  epInfo[i].maxPktSize = (i) ? 0 : 8;
32  epInfo[i].epAttribs = 0;
34  }
35 
36  if (pUsb) // register in USB subsystem
37  pUsb->RegisterDeviceClass(this); //set devConfig[] entry
38 }
39 
40 uint8_t XBOXRECV::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
41  const uint8_t constBufSize = sizeof (USB_DEVICE_DESCRIPTOR);
42  uint8_t buf[constBufSize];
43  uint8_t rcode;
44  UsbDevice *p = NULL;
45  EpInfo *oldep_ptr = NULL;
46  uint16_t PID, VID;
47 
48  AddressPool &addrPool = pUsb->GetAddressPool(); // Get memory address of USB device address pool
49 #ifdef EXTRADEBUG
50  Notify(PSTR("\r\nXBOXRECV Init"), 0x80);
51 #endif
52 
53  if (bAddress) { // Check if address has already been assigned to an instance
54 #ifdef DEBUG_USB_HOST
55  Notify(PSTR("\r\nAddress in use"), 0x80);
56 #endif
58  }
59 
60  p = addrPool.GetUsbDevicePtr(0); // Get pointer to pseudo device with address 0 assigned
61 
62  if (!p) {
63 #ifdef DEBUG_USB_HOST
64  Notify(PSTR("\r\nAddress not found"), 0x80);
65 #endif
67  }
68 
69  if (!p->epinfo) {
70 #ifdef DEBUG_USB_HOST
71  Notify(PSTR("\r\nepinfo is null"), 0x80);
72 #endif
74  }
75 
76  oldep_ptr = p->epinfo; // Save old pointer to EP_RECORD of address 0
77  p->epinfo = epInfo; // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
78  p->lowspeed = lowspeed;
79 
80  rcode = pUsb->getDevDescr(0, 0, constBufSize, (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data
81 
82  p->epinfo = oldep_ptr; // Restore p->epinfo
83 
84  if (rcode)
85  goto FailGetDevDescr;
86 
87  VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
88  PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
89 
90  if ((VID != XBOX_VID && VID != MADCATZ_VID) || (PID != XBOX_WIRELESS_RECEIVER_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID)) { // Check if it's a Xbox receiver using the Vendor ID and Product ID
91 #ifdef DEBUG_USB_HOST
92  Notify(PSTR("\r\nYou'll need a wireless receiver for this libary to work"), 0x80);
93 #endif
94  goto FailUnknownDevice;
95  }
96 
97  bAddress = addrPool.AllocAddress(parent, false, port); // Allocate new address according to device class
98 
99  if (!bAddress) {
100 #ifdef DEBUG_USB_HOST
101  Notify(PSTR("\r\nOut of address space"), 0x80);
102 #endif
104  }
105 
106  epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; // Extract Max Packet Size from device descriptor
107  epInfo[1].epAddr = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; // Steal and abuse from epInfo structure to save memory
108 
109  delay(20); // Wait a little before resetting device
110 
112 
113  /* Diagnostic messages */
114 FailGetDevDescr:
115 #ifdef DEBUG_USB_HOST
116  NotifyFailGetDevDescr(rcode);
117 #endif
118  if (rcode != hrJERR)
120  goto Fail;
121 
122 FailUnknownDevice:
123 #ifdef DEBUG_USB_HOST
124  NotifyFailUnknownDevice(VID,PID);
125 #endif
127 
128 Fail:
129 #ifdef DEBUG_USB_HOST
130  Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
131  NotifyFail(rcode);
132 #endif
133  Release();
134  return rcode;
135 };
136 
137 uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
138  uint8_t rcode;
139  uint8_t num_of_conf = epInfo[1].epAddr; // Number of configurations
140  epInfo[1].epAddr = 0;
141 
142  AddressPool &addrPool = pUsb->GetAddressPool();
143 #ifdef EXTRADEBUG
144  Notify(PSTR("\r\nBTD Init"), 0x80);
145 #endif
146  UsbDevice *p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record
147 
148  if (!p) {
149 #ifdef DEBUG_USB_HOST
150  Notify(PSTR("\r\nAddress not found"), 0x80);
151 #endif
153  }
154 
155  delay(300); // Assign new address to the device
156 
157  rcode = pUsb->setAddr(0, 0, bAddress); // Assign new address to the device
158  if (rcode) {
159 #ifdef DEBUG_USB_HOST
160  Notify(PSTR("\r\nsetAddr: "), 0x80);
161  D_PrintHex<uint8_t > (rcode, 0x80);
162 #endif
163  p->lowspeed = false;
164  goto Fail;
165  }
166 #ifdef EXTRADEBUG
167  Notify(PSTR("\r\nAddr: "), 0x80);
168  D_PrintHex<uint8_t > (bAddress, 0x80);
169 #endif
170 
171  p->lowspeed = false;
172 
173  p = addrPool.GetUsbDevicePtr(bAddress); // Get pointer to assigned address record
174  if (!p) {
175 #ifdef DEBUG_USB_HOST
176  Notify(PSTR("\r\nAddress not found"), 0x80);
177 #endif
179  }
180 
181  p->lowspeed = lowspeed;
182 
183  rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo); // Assign epInfo to epinfo pointer - only EP0 is known
184  if (rcode)
185  goto FailSetDevTblEntry;
186 
187  /* The application will work in reduced host mode, so we can save program and data
188  memory space. After verifying the VID we will use known values for the
189  configuration values for device, interface, endpoints and HID for the XBOX360 Wireless receiver */
190 
191  /* Initialize data structures for endpoints of device */
192  epInfo[ XBOX_INPUT_PIPE_1 ].epAddr = 0x01; // XBOX 360 report endpoint - poll interval 1ms
194  epInfo[ XBOX_INPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
198  epInfo[ XBOX_OUTPUT_PIPE_1 ].epAddr = 0x01; // XBOX 360 output endpoint - poll interval 8ms
200  epInfo[ XBOX_OUTPUT_PIPE_1 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
204 
205  epInfo[ XBOX_INPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 report endpoint - poll interval 1ms
207  epInfo[ XBOX_INPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
211  epInfo[ XBOX_OUTPUT_PIPE_2 ].epAddr = 0x03; // XBOX 360 output endpoint - poll interval 8ms
213  epInfo[ XBOX_OUTPUT_PIPE_2 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
217 
218  epInfo[ XBOX_INPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 report endpoint - poll interval 1ms
220  epInfo[ XBOX_INPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
224  epInfo[ XBOX_OUTPUT_PIPE_3 ].epAddr = 0x05; // XBOX 360 output endpoint - poll interval 8ms
226  epInfo[ XBOX_OUTPUT_PIPE_3 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
230 
231  epInfo[ XBOX_INPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 report endpoint - poll interval 1ms
233  epInfo[ XBOX_INPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
237  epInfo[ XBOX_OUTPUT_PIPE_4 ].epAddr = 0x07; // XBOX 360 output endpoint - poll interval 8ms
239  epInfo[ XBOX_OUTPUT_PIPE_4 ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
243 
244  rcode = pUsb->setEpInfoEntry(bAddress, 9, epInfo);
245  if (rcode)
246  goto FailSetDevTblEntry;
247 
248  delay(200); //Give time for address change
249 
250  rcode = pUsb->setConf(bAddress, epInfo[ XBOX_CONTROL_PIPE ].epAddr, 1);
251  if (rcode)
252  goto FailSetConfDescr;
253 
254 #ifdef DEBUG_USB_HOST
255  Notify(PSTR("\r\nXbox Wireless Receiver Connected\r\n"), 0x80);
256 #endif
257  XboxReceiverConnected = true;
258  bPollEnable = true;
259  checkStatusTimer = 0; // Reset timer
260  return 0; // Successful configuration
261 
262  /* Diagnostic messages */
263 FailGetDevDescr:
264 #ifdef DEBUG_USB_HOST
266  goto Fail;
267 #endif
268 
269 FailSetDevTblEntry:
270 #ifdef DEBUG_USB_HOST
272  goto Fail;
273 #endif
274 
275 FailSetConfDescr:
276 #ifdef DEBUG_USB_HOST
278 #endif
279  goto Fail;
280 
281 Fail:
282 #ifdef DEBUG_USB_HOST
283  Notify(PSTR("\r\nXbox 360 Init Failed, error code: "), 0x80);
284  NotifyFail(rcode);
285 #endif
286  Release();
287  return rcode;
288 }
289 
290 /* Performs a cleanup after failed Init() attempt */
291 uint8_t XBOXRECV::Release() {
292  XboxReceiverConnected = false;
293  for (uint8_t i = 0; i < 4; i++)
294  Xbox360Connected[i] = 0x00;
296  bAddress = 0;
297  bPollEnable = false;
298  return 0;
299 }
300 
301 uint8_t XBOXRECV::Poll() {
302  if (!bPollEnable)
303  return 0;
304  if (!checkStatusTimer || ((millis() - checkStatusTimer) > 3000)) { // Run checkStatus every 3 seconds
305  checkStatusTimer = millis();
306  checkStatus();
307  }
308 
309  uint8_t inputPipe;
310  uint16_t bufferSize;
311  for (uint8_t i = 0; i < 4; i++) {
312  if (i == 0)
313  inputPipe = XBOX_INPUT_PIPE_1;
314  else if (i == 1)
315  inputPipe = XBOX_INPUT_PIPE_2;
316  else if (i == 2)
317  inputPipe = XBOX_INPUT_PIPE_3;
318  else
319  inputPipe = XBOX_INPUT_PIPE_4;
320 
321  bufferSize = EP_MAXPKTSIZE; // This is the maximum number of bytes we want to receive
322  pUsb->inTransfer(bAddress, epInfo[ inputPipe ].epAddr, &bufferSize, readBuf);
323  if (bufferSize > 0) { // The number of received bytes
324 #ifdef EXTRADEBUG
325  Notify(PSTR("Bytes Received: "), 0x80);
326  D_PrintHex<uint16_t > (bufferSize, 0x80);
327  Notify(PSTR("\r\n"), 0x80);
328 #endif
329  readReport(i);
330 #ifdef PRINTREPORT
331  printReport(i, bufferSize); // Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller
332 #endif
333  }
334  }
335  return 0;
336 }
337 
338 void XBOXRECV::readReport(uint8_t controller) {
339  if (readBuf == NULL)
340  return;
341  // This report is send when a controller is connected and disconnected
342  if (readBuf[0] == 0x08 && readBuf[1] != Xbox360Connected[controller]) {
343  Xbox360Connected[controller] = readBuf[1];
344 #ifdef DEBUG_USB_HOST
345  Notify(PSTR("Controller "), 0x80);
346  Notify(controller, 0x80);
347 #endif
348  if (Xbox360Connected[controller]) {
349 #ifdef DEBUG_USB_HOST
350  const char* str = 0;
351  switch (readBuf[1]) {
352  case 0x80: str = PSTR(" as controller\r\n");
353  break;
354  case 0x40: str = PSTR(" as headset\r\n");
355  break;
356  case 0xC0: str = PSTR(" as controller+headset\r\n");
357  break;
358  }
359  Notify(PSTR(": connected"), 0x80);
360  Notify(str, 0x80);
361 #endif
362  onInit(controller);
363  }
364 #ifdef DEBUG_USB_HOST
365  else
366  Notify(PSTR(": disconnected\r\n"), 0x80);
367 #endif
368  return;
369  }
370  // Controller status report
371  if (readBuf[1] == 0x00 && readBuf[3] & 0x13 && readBuf[4] >= 0x22) {
372  controllerStatus[controller] = ((uint16_t)readBuf[3] << 8) | readBuf[4];
373  return;
374  }
375  if (readBuf[1] != 0x01) // Check if it's the correct report - the receiver also sends different status reports
376  return;
377 
378  // A controller must be connected if it's sending data
379  if (!Xbox360Connected[controller])
380  Xbox360Connected[controller] |= 0x80;
381 
382  ButtonState[controller] = (uint32_t)(readBuf[9] | ((uint16_t)readBuf[8] << 8) | ((uint32_t)readBuf[7] << 16) | ((uint32_t)readBuf[6] << 24));
383 
384  hatValue[controller][LeftHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
385  hatValue[controller][LeftHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
386  hatValue[controller][RightHatX] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]);
387  hatValue[controller][RightHatY] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]);
388 
389  //Notify(PSTR("\r\nButtonState: "), 0x80);
390  //PrintHex<uint32_t>(ButtonState[controller], 0x80);
391 
392  if (ButtonState[controller] != OldButtonState[controller]) {
393  buttonStateChanged[controller] = true;
394  ButtonClickState[controller] = (ButtonState[controller] >> 16) & ((~OldButtonState[controller]) >> 16); // Update click state variable, but don't include the two trigger buttons L2 and R2
395  if (((uint8_t)OldButtonState[controller]) == 0 && ((uint8_t)ButtonState[controller]) != 0) // The L2 and R2 buttons are special as they are analog buttons
396  R2Clicked[controller] = true;
397  if ((uint8_t)(OldButtonState[controller] >> 8) == 0 && (uint8_t)(ButtonState[controller] >> 8) != 0)
398  L2Clicked[controller] = true;
399  OldButtonState[controller] = ButtonState[controller];
400  }
401 }
402 
403 void XBOXRECV::printReport(uint8_t controller, uint8_t nBytes) { //Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller
404 #ifdef PRINTREPORT
405  if (readBuf == NULL)
406  return;
407  Notify(PSTR("Controller "), 0x80);
408  Notify(controller, 0x80);
409  Notify(PSTR(": "), 0x80);
410  for (uint8_t i = 0; i < nBytes; i++) {
411  D_PrintHex<uint8_t > (readBuf[i], 0x80);
412  Notify(PSTR(" "), 0x80);
413  }
414  Notify(PSTR("\r\n"), 0x80);
415 #endif
416 }
417 
418 uint8_t XBOXRECV::getButtonPress(Button b, uint8_t controller) {
419  if (b == L2) // These are analog buttons
420  return (uint8_t)(ButtonState[controller] >> 8);
421  else if (b == R2)
422  return (uint8_t)ButtonState[controller];
423  return (bool)(ButtonState[controller] & ((uint32_t)pgm_read_word(&XBOXBUTTONS[(uint8_t)b]) << 16));
424 }
425 
426 bool XBOXRECV::getButtonClick(Button b, uint8_t controller) {
427  if (b == L2) {
428  if (L2Clicked[controller]) {
429  L2Clicked[controller] = false;
430  return true;
431  }
432  return false;
433  } else if (b == R2) {
434  if (R2Clicked[controller]) {
435  R2Clicked[controller] = false;
436  return true;
437  }
438  return false;
439  }
440  uint16_t button = pgm_read_word(&XBOXBUTTONS[(uint8_t)b]);
441  bool click = (ButtonClickState[controller] & button);
442  ButtonClickState[controller] &= ~button; // clear "click" event
443  return click;
444 }
445 
446 int16_t XBOXRECV::getAnalogHat(AnalogHat a, uint8_t controller) {
447  return hatValue[controller][a];
448 }
449 
450 bool XBOXRECV::buttonChanged(uint8_t controller) {
451  bool state = buttonStateChanged[controller];
452  buttonStateChanged[controller] = false;
453  return state;
454 }
455 
456 /*
457 ControllerStatus Breakdown
458 ControllerStatus[controller] & 0x0001 // 0
459 ControllerStatus[controller] & 0x0002 // normal batteries, no rechargeable battery pack
460 ControllerStatus[controller] & 0x0004 // controller starting up / settling
461 ControllerStatus[controller] & 0x0008 // headset adapter plugged in, but no headphones connected (mute?)
462 ControllerStatus[controller] & 0x0010 // 0
463 ControllerStatus[controller] & 0x0020 // 1
464 ControllerStatus[controller] & 0x0040 // battery level (high bit)
465 ControllerStatus[controller] & 0x0080 // battery level (low bit)
466 ControllerStatus[controller] & 0x0100 // 1
467 ControllerStatus[controller] & 0x0200 // 1
468 ControllerStatus[controller] & 0x0400 // headset adapter plugged in
469 ControllerStatus[controller] & 0x0800 // 0
470 ControllerStatus[controller] & 0x1000 // 1
471 ControllerStatus[controller] & 0x2000 // 0
472 ControllerStatus[controller] & 0x4000 // 0
473 ControllerStatus[controller] & 0x8000 // 0
474  */
475 uint8_t XBOXRECV::getBatteryLevel(uint8_t controller) {
476  return ((controllerStatus[controller] & 0x00C0) >> 6);
477 }
478 
479 void XBOXRECV::XboxCommand(uint8_t controller, uint8_t* data, uint16_t nbytes) {
480  uint8_t outputPipe;
481  if (controller == 0)
482  outputPipe = XBOX_OUTPUT_PIPE_1;
483  else if (controller == 1)
484  outputPipe = XBOX_OUTPUT_PIPE_2;
485  else if (controller == 2)
486  outputPipe = XBOX_OUTPUT_PIPE_3;
487  else
488  outputPipe = XBOX_OUTPUT_PIPE_4;
489 
490  uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ outputPipe ].epAddr, nbytes, data);
491 #ifdef EXTRADEBUG
492  if (rcode)
493  Notify(PSTR("Error sending Xbox message\r\n"), 0x80);
494 #endif
495 }
496 
497 void XBOXRECV::disconnect(uint8_t controller) {
498  writeBuf[0] = 0x00;
499  writeBuf[1] = 0x00;
500  writeBuf[2] = 0x08;
501  writeBuf[3] = 0xC0;
502 
503  XboxCommand(controller, writeBuf, 4);
504 }
505 
506 void XBOXRECV::setLedRaw(uint8_t value, uint8_t controller) {
507  writeBuf[0] = 0x00;
508  writeBuf[1] = 0x00;
509  writeBuf[2] = 0x08;
510  writeBuf[3] = value | 0x40;
511 
512  XboxCommand(controller, writeBuf, 4);
513 }
514 
515 void XBOXRECV::setLedOn(LED led, uint8_t controller) {
516  if (led != ALL) // All LEDs can't be on a the same time
517  setLedRaw(pgm_read_byte(&XBOXLEDS[(uint8_t)led]) + 4, controller);
518 }
519 
520 void XBOXRECV::setLedBlink(LED led, uint8_t controller) {
521  setLedRaw(pgm_read_byte(&XBOXLEDS[(uint8_t)led]), controller);
522 }
523 
524 void XBOXRECV::setLedMode(LEDMode ledMode, uint8_t controller) { // This function is used to do some speciel LED stuff the controller supports
525  setLedRaw((uint8_t)ledMode, controller);
526 }
527 
528 /* PC runs this at interval of approx 2 seconds
529 Thanks to BusHound from Perisoft.net for the Windows USB Analysis output
530 Found by timstamp.co.uk
531  */
532 void XBOXRECV::checkStatus() {
533  if (!bPollEnable)
534  return;
535  // Get controller info
536  writeBuf[0] = 0x08;
537  writeBuf[1] = 0x00;
538  writeBuf[2] = 0x0f;
539  writeBuf[3] = 0xc0;
540  for (uint8_t i = 0; i < 4; i++) {
541  XboxCommand(i, writeBuf, 4);
542  }
543  // Get battery status
544  writeBuf[0] = 0x00;
545  writeBuf[1] = 0x00;
546  writeBuf[2] = 0x00;
547  writeBuf[3] = 0x40;
548  for (uint8_t i = 0; i < 4; i++) {
549  if (Xbox360Connected[i])
550  XboxCommand(i, writeBuf, 4);
551  }
552 }
553 
554 void XBOXRECV::setRumbleOn(uint8_t lValue, uint8_t rValue, uint8_t controller) {
555  writeBuf[0] = 0x00;
556  writeBuf[1] = 0x01;
557  writeBuf[2] = 0x0f;
558  writeBuf[3] = 0xc0;
559  writeBuf[4] = 0x00;
560  writeBuf[5] = lValue; // big weight
561  writeBuf[6] = rValue; // small weight
562 
563  XboxCommand(controller, writeBuf, 7);
564 }
565 
566 void XBOXRECV::onInit(uint8_t controller) {
567  if (pFuncOnInit)
568  pFuncOnInit(); // Call the user function
569  else {
570  LED led;
571  if (controller == 0)
572  led = LED1;
573  else if (controller == 1)
574  led = LED2;
575  else if (controller == 2)
576  led = LED3;
577  else
578  led = LED4;
579  setLedOn(led, controller);
580  }
581 }
uint8_t bmRcvToggle
Definition: address.h:41
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID
Definition: XBOXRECV.h:49
bool getButtonClick(Button b, uint8_t controller=0)
Definition: XBOXRECV.cpp:426
EpInfo * epinfo
Definition: address.h:76
bool lowspeed
Definition: address.h:79
#define USB_ERROR_EPINFO_IS_NULL
Definition: UsbCore.h:67
virtual uint8_t Poll()
Definition: XBOXRECV.cpp:301
void setRumbleOn(uint8_t lValue, uint8_t rValue, uint8_t controller=0)
Definition: XBOXRECV.cpp:554
uint8_t bmNakPower
Definition: address.h:42
#define XBOX_WIRELESS_RECEIVER_PID
Definition: XBOXRECV.h:48
uint8_t bAddress
Definition: XBOXRECV.h:241
#define NotifyFail(...)
Definition: message.h:55
uint8_t Xbox360Connected[4]
Definition: XBOXRECV.h:235
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:798
bool buttonChanged(uint8_t controller=0)
Definition: XBOXRECV.cpp:450
#define XBOX_OUTPUT_PIPE_3
Definition: XBOXRECV.h:39
virtual uint8_t ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed)
Definition: XBOXRECV.cpp:40
#define USB_ERROR_FailGetDevDescr
Definition: UsbCore.h:73
#define NotifyFailGetDevDescr(...)
Definition: message.h:50
const uint16_t XBOXBUTTONS[]
Definition: xboxEnums.h:40
#define hrJERR
Definition: max3421e.h:225
const uint8_t XBOXLEDS[]
Definition: xboxEnums.h:32
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
#define EP_MAXPKTSIZE
Definition: PS3USB.h:25
virtual void FreeAddress(uint8_t addr)=0
uint8_t epAttribs
Definition: address.h:37
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
#define Notify(...)
Definition: message.h:44
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:793
uint8_t epAddr
Definition: address.h:33
#define XBOX_INPUT_PIPE_2
Definition: XBOXRECV.h:36
#define NotifyFailUnknownDevice(...)
Definition: message.h:54
#define USB_NAK_MAX_POWER
Definition: address.h:27
#define XBOX_VID
Definition: XBOXOLD.h:36
virtual uint8_t Release()
Definition: XBOXRECV.cpp:291
#define EP_INTERRUPT
Definition: PS3USB.h:28
Definition: address.h:32
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:290
bool XboxReceiverConnected
Definition: XBOXRECV.h:229
void setLedBlink(LED l, uint8_t controller=0)
Definition: XBOXRECV.cpp:520
void setLedOn(LED l, uint8_t controller=0)
Definition: XBOXRECV.cpp:515
uint8_t getBatteryLevel(uint8_t controller=0)
Definition: XBOXRECV.cpp:475
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
#define XBOX_OUTPUT_PIPE_1
Definition: XBOXRECV.h:35
LEDMode
Definition: xboxEnums.h:24
uint8_t bmSndToggle
Definition: address.h:40
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
Definition: UsbCore.h:69
XBOXRECV(USB *pUsb)
Definition: XBOXRECV.cpp:25
#define MADCATZ_VID
Definition: XBOXOLD.h:37
#define XBOX_INPUT_PIPE_1
Definition: XBOXRECV.h:34
#define USB_NAK_NOWAIT
Definition: address.h:29
void setLedMode(LEDMode lm, uint8_t controller=0)
Definition: XBOXRECV.cpp:524
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:66
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: XBOXRECV.cpp:137
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data)
Definition: Usb.cpp:206
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
Definition: UsbCore.h:61
void setLedRaw(uint8_t value, uint8_t controller=0)
Definition: XBOXRECV.cpp:506
#define XBOX_MAX_ENDPOINTS
Definition: XBOXOLD.h:49
#define bmRCVTOG0
Definition: max3421e.h:185
int16_t getAnalogHat(AnalogHat a, uint8_t controller=0)
Definition: XBOXRECV.cpp:446
#define USB_ERROR_OUT_OF_ADDRESS_SPACE_IN_POOL
Definition: UsbCore.h:64
Button
#define bmSNDTOG0
Definition: max3421e.h:187
uint8_t maxPktSize
Definition: address.h:34
AddressPool & GetAddressPool()
Definition: UsbCore.h:168
Definition: UsbCore.h:152
#define XBOX_INPUT_PIPE_3
Definition: XBOXRECV.h:38
#define XBOX_CONTROL_PIPE
Definition: XBOXOLD.h:31
uint8_t getButtonPress(Button b, uint8_t controller=0)
Definition: XBOXRECV.cpp:418
#define XBOX_INPUT_PIPE_4
Definition: XBOXRECV.h:40
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
Definition: UsbCore.h:172
#define NotifyFailSetConfDescr(...)
Definition: message.h:53
void disconnect(uint8_t controller=0)
Definition: XBOXRECV.cpp:497
AnalogHat
#define XBOX_OUTPUT_PIPE_4
Definition: XBOXRECV.h:41
USB * pUsb
Definition: XBOXRECV.h:239
#define XBOX_OUTPUT_PIPE_2
Definition: XBOXRECV.h:37
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:759
EpInfo epInfo[XBOX_MAX_ENDPOINTS]
Definition: XBOXRECV.h:243
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:51
#define USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET
Definition: UsbCore.h:72