USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PS3USB.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 
18 #include "PS3USB.h"
19 // To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
20 //#define EXTRADEBUG // Uncomment to get even more debugging data
21 //#define PRINTREPORT // Uncomment to print the report send by the PS3 Controllers
22 
23 PS3USB::PS3USB(USB *p, uint8_t btadr5, uint8_t btadr4, uint8_t btadr3, uint8_t btadr2, uint8_t btadr1, uint8_t btadr0) :
24 pUsb(p), // pointer to USB class instance - mandatory
25 bAddress(0), // device address - mandatory
26 bPollEnable(false) // don't start polling before dongle is connected
27 {
28  for (uint8_t i = 0; i < PS3_MAX_ENDPOINTS; i++) {
29  epInfo[i].epAddr = 0;
30  epInfo[i].maxPktSize = (i) ? 0 : 8;
31  epInfo[i].epAttribs = 0;
33  }
34 
35  if (pUsb) // register in USB subsystem
36  pUsb->RegisterDeviceClass(this); //set devConfig[] entry
37 
38  my_bdaddr[5] = btadr5; // Change to your dongle's Bluetooth address instead
39  my_bdaddr[4] = btadr4;
40  my_bdaddr[3] = btadr3;
41  my_bdaddr[2] = btadr2;
42  my_bdaddr[1] = btadr1;
43  my_bdaddr[0] = btadr0;
44 }
45 
46 uint8_t PS3USB::Init(uint8_t parent, uint8_t port, bool lowspeed) {
47  uint8_t buf[sizeof (USB_DEVICE_DESCRIPTOR)];
48  uint8_t rcode;
49  UsbDevice *p = NULL;
50  EpInfo *oldep_ptr = NULL;
51  uint16_t PID;
52  uint16_t VID;
53 
54  // get memory address of USB device address pool
55  AddressPool &addrPool = pUsb->GetAddressPool();
56 #ifdef EXTRADEBUG
57  Notify(PSTR("\r\nPS3USB Init"), 0x80);
58 #endif
59  // check if address has already been assigned to an instance
60  if (bAddress) {
61 #ifdef DEBUG_USB_HOST
62  Notify(PSTR("\r\nAddress in use"), 0x80);
63 #endif
65  }
66 
67  // Get pointer to pseudo device with address 0 assigned
68  p = addrPool.GetUsbDevicePtr(0);
69 
70  if (!p) {
71 #ifdef DEBUG_USB_HOST
72  Notify(PSTR("\r\nAddress not found"), 0x80);
73 #endif
75  }
76 
77  if (!p->epinfo) {
78 #ifdef DEBUG_USB_HOST
79  Notify(PSTR("\r\nepinfo is null"), 0x80);
80 #endif
82  }
83 
84  // Save old pointer to EP_RECORD of address 0
85  oldep_ptr = p->epinfo;
86 
87  // Temporary assign new pointer to epInfo to p->epinfo in order to avoid toggle inconsistence
88  p->epinfo = epInfo;
89 
90  p->lowspeed = lowspeed;
91 
92  // Get device descriptor
93  rcode = pUsb->getDevDescr(0, 0, sizeof (USB_DEVICE_DESCRIPTOR), (uint8_t*)buf); // Get device descriptor - addr, ep, nbytes, data
94  // Restore p->epinfo
95  p->epinfo = oldep_ptr;
96 
97  if (rcode)
98  goto FailGetDevDescr;
99 
100  VID = ((USB_DEVICE_DESCRIPTOR*)buf)->idVendor;
101  PID = ((USB_DEVICE_DESCRIPTOR*)buf)->idProduct;
102 
103  if (VID != PS3_VID || (PID != PS3_PID && PID != PS3NAVIGATION_PID && PID != PS3MOVE_PID))
104  goto FailUnknownDevice;
105 
106  // Allocate new address according to device class
107  bAddress = addrPool.AllocAddress(parent, false, port);
108 
109  if (!bAddress)
111 
112  // Extract Max Packet Size from device descriptor
113  epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0;
114 
115  // Assign new address to the device
116  rcode = pUsb->setAddr(0, 0, bAddress);
117  if (rcode) {
118  p->lowspeed = false;
119  addrPool.FreeAddress(bAddress);
120  bAddress = 0;
121 #ifdef DEBUG_USB_HOST
122  Notify(PSTR("\r\nsetAddr: "), 0x80);
123  D_PrintHex<uint8_t > (rcode, 0x80);
124 #endif
125  return rcode;
126  }
127 #ifdef EXTRADEBUG
128  Notify(PSTR("\r\nAddr: "), 0x80);
129  D_PrintHex<uint8_t > (bAddress, 0x80);
130 #endif
131  delay(300); // Spec says you should wait at least 200ms
132 
133  p->lowspeed = false;
134 
135  //get pointer to assigned address record
136  p = addrPool.GetUsbDevicePtr(bAddress);
137  if (!p)
139 
140  p->lowspeed = lowspeed;
141 
142  // Assign epInfo to epinfo pointer - only EP0 is known
143  rcode = pUsb->setEpInfoEntry(bAddress, 1, epInfo);
144  if (rcode)
145  goto FailSetDevTblEntry;
146 
147 
148  /* The application will work in reduced host mode, so we can save program and data
149  memory space. After verifying the PID and VID we will use known values for the
150  configuration values for device, interface, endpoints and HID for the PS3 Controllers */
151 
152  /* Initialize data structures for endpoints of device */
153  epInfo[ PS3_OUTPUT_PIPE ].epAddr = 0x02; // PS3 output endpoint
155  epInfo[ PS3_OUTPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
159  epInfo[ PS3_INPUT_PIPE ].epAddr = 0x01; // PS3 report endpoint
161  epInfo[ PS3_INPUT_PIPE ].bmNakPower = USB_NAK_NOWAIT; // Only poll once for interrupt endpoints
165 
166  rcode = pUsb->setEpInfoEntry(bAddress, 3, epInfo);
167  if (rcode)
168  goto FailSetDevTblEntry;
169 
170  delay(200); //Give time for address change
171 
172  rcode = pUsb->setConf(bAddress, epInfo[ PS3_CONTROL_PIPE ].epAddr, 1);
173  if (rcode)
174  goto FailSetConfDescr;
175 
176  if (PID == PS3_PID || PID == PS3NAVIGATION_PID) {
177  if (PID == PS3_PID) {
178 #ifdef DEBUG_USB_HOST
179  Notify(PSTR("\r\nDualshock 3 Controller Connected"), 0x80);
180 #endif
181  PS3Connected = true;
182  } else { // must be a navigation controller
183 #ifdef DEBUG_USB_HOST
184  Notify(PSTR("\r\nNavigation Controller Connected"), 0x80);
185 #endif
186  PS3NavigationConnected = true;
187  }
188  enable_sixaxis(); // The PS3 controller needs a special command before it starts sending data
189 
190  // Needed for PS3 Dualshock and Navigation commands to work
191  for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++)
192  writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]);
193 
194  for (uint8_t i = 6; i < 10; i++)
195  readBuf[i] = 0x7F; // Set the analog joystick values to center position
196  } else { // must be a Motion controller
197 #ifdef DEBUG_USB_HOST
198  Notify(PSTR("\r\nMotion Controller Connected"), 0x80);
199 #endif
200  PS3MoveConnected = true;
201  writeBuf[0] = 0x02; // Set report ID, this is needed for Move commands to work
202  }
203  if (my_bdaddr[0] != 0x00 || my_bdaddr[1] != 0x00 || my_bdaddr[2] != 0x00 || my_bdaddr[3] != 0x00 || my_bdaddr[4] != 0x00 || my_bdaddr[5] != 0x00) {
204  if (PS3MoveConnected)
205  setMoveBdaddr(my_bdaddr); // Set internal Bluetooth address
206  else
207  setBdaddr(my_bdaddr); // Set internal Bluetooth address
208 
209 #ifdef DEBUG_USB_HOST
210  Notify(PSTR("\r\nBluetooth Address was set to: "), 0x80);
211  for (int8_t i = 5; i > 0; i--) {
212  D_PrintHex<uint8_t > (my_bdaddr[i], 0x80);
213  Notify(PSTR(":"), 0x80);
214  }
215  D_PrintHex<uint8_t > (my_bdaddr[0], 0x80);
216 #endif
217  }
218  onInit();
219 
220  bPollEnable = true;
221  Notify(PSTR("\r\n"), 0x80);
222  timer = millis();
223  return 0; // successful configuration
224 
225  /* diagnostic messages */
226 FailGetDevDescr:
227 #ifdef DEBUG_USB_HOST
229  goto Fail;
230 #endif
231 FailSetDevTblEntry:
232 #ifdef DEBUG_USB_HOST
234  goto Fail;
235 #endif
236 
237 FailSetConfDescr:
238 #ifdef DEBUG_USB_HOST
240 #endif
241  goto Fail;
242 FailUnknownDevice:
243 #ifdef DEBUG_USB_HOST
244  NotifyFailUnknownDevice(VID, PID);
245 #endif
247 Fail:
248 
249 #ifdef DEBUG_USB_HOST
250  Notify(PSTR("\r\nPS3 Init Failed, error code: "), 0x80);
251  NotifyFail(rcode);
252 #endif
253  Release();
254  return rcode;
255 }
256 
257 /* Performs a cleanup after failed Init() attempt */
258 uint8_t PS3USB::Release() {
259  PS3Connected = false;
260  PS3MoveConnected = false;
261  PS3NavigationConnected = false;
263  bAddress = 0;
264  bPollEnable = false;
265  return 0;
266 }
267 
268 uint8_t PS3USB::Poll() {
269  if (!bPollEnable)
270  return 0;
271 
273  uint16_t BUFFER_SIZE = EP_MAXPKTSIZE;
274  pUsb->inTransfer(bAddress, epInfo[ PS3_INPUT_PIPE ].epAddr, &BUFFER_SIZE, readBuf); // input on endpoint 1
275  if (millis() - timer > 100) { // Loop 100ms before processing data
276  readReport();
277 #ifdef PRINTREPORT
278  printReport(); // Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
279 #endif
280  }
281  } else if (PS3MoveConnected) { // One can only set the color of the bulb, set the rumble, set and get the bluetooth address and calibrate the magnetometer via USB
282  if (millis() - timer > 4000) // Send at least every 4th second
283  {
284  Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE); // The Bulb and rumble values, has to be written again and again, for it to stay turned on
285  timer = millis();
286  }
287  }
288  return 0;
289 }
290 
291 void PS3USB::readReport() {
292  if (readBuf == NULL)
293  return;
294 
295  ButtonState = (uint32_t)(readBuf[2] | ((uint16_t)readBuf[3] << 8) | ((uint32_t)readBuf[4] << 16));
296 
297  //Notify(PSTR("\r\nButtonState", 0x80);
298  //PrintHex<uint32_t>(ButtonState, 0x80);
299 
300  if (ButtonState != OldButtonState) {
301  ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
302  OldButtonState = ButtonState;
303  }
304 }
305 
306 void PS3USB::printReport() { //Uncomment "#define PRINTREPORT" to print the report send by the PS3 Controllers
307 #ifdef PRINTREPORT
308  if (readBuf == NULL)
309  return;
310  for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++) {
311  D_PrintHex<uint8_t > (readBuf[i], 0x80);
312  Notify(PSTR(" "), 0x80);
313  }
314  Notify(PSTR("\r\n"), 0x80);
315 #endif
316 }
317 
319  return (ButtonState & pgm_read_dword(&BUTTONS[(uint8_t)b]));
320 }
321 
323  uint32_t button = pgm_read_dword(&BUTTONS[(uint8_t)b]);
324  bool click = (ButtonClickState & button);
325  ButtonClickState &= ~button; // clear "click" event
326  return click;
327 }
328 
330  if (readBuf == NULL)
331  return 0;
332  return (uint8_t)(readBuf[(pgm_read_byte(&ANALOGBUTTONS[(uint8_t)a])) - 9]);
333 }
334 
336  if (readBuf == NULL)
337  return 0;
338  return (uint8_t)(readBuf[((uint8_t)a + 6)]);
339 }
340 
342  if (readBuf == NULL)
343  return 0;
344  return ((readBuf[((uint16_t)a) - 9] << 8) | readBuf[((uint16_t)a + 1) - 9]);
345 }
346 
348  if (PS3Connected) {
349  double accXval;
350  double accYval;
351  double accZval;
352 
353  // Data for the Kionix KXPC4 used in the DualShock 3
354  const double zeroG = 511.5; // 1.65/3.3*1023 (1,65V)
355  accXval = -((double)getSensor(aX) - zeroG);
356  accYval = -((double)getSensor(aY) - zeroG);
357  accZval = -((double)getSensor(aZ) - zeroG);
358 
359  // Convert to 360 degrees resolution
360  // atan2 outputs the value of -Ï€ to Ï€ (radians)
361  // We are then converting it to 0 to 2Ï€ and then to degrees
362  if (a == Pitch) {
363  double angle = (atan2(accYval, accZval) + PI) * RAD_TO_DEG;
364  return angle;
365  } else {
366  double angle = (atan2(accXval, accZval) + PI) * RAD_TO_DEG;
367  return angle;
368  }
369  } else
370  return 0;
371 }
372 
374  if (readBuf == NULL)
375  return false;
376  if (readBuf[((uint16_t)c >> 8) - 9] == ((uint8_t)c & 0xff))
377  return true;
378  return false;
379 }
380 
383  char statusOutput[100];
384 
385  strcpy(statusOutput, "ConnectionStatus: ");
386 
387  if (getStatus(Plugged)) strcat(statusOutput, "Plugged");
388  else if (getStatus(Unplugged)) strcat(statusOutput, "Unplugged");
389  else strcat(statusOutput, "Error");
390 
391 
392  strcat(statusOutput, " - PowerRating: ");
393 
394  if (getStatus(Charging)) strcat(statusOutput, "Charging");
395  else if (getStatus(NotCharging)) strcat(statusOutput, "Not Charging");
396  else if (getStatus(Shutdown)) strcat(statusOutput, "Shutdown");
397  else if (getStatus(Dying)) strcat(statusOutput, "Dying");
398  else if (getStatus(Low)) strcat(statusOutput, "Low");
399  else if (getStatus(High)) strcat(statusOutput, "High");
400  else if (getStatus(Full)) strcat(statusOutput, "Full");
401  else strcat(statusOutput, "Error");
402 
403  strcat(statusOutput, " - WirelessStatus: ");
404 
405  if (getStatus(CableRumble)) strcat(statusOutput, "Cable - Rumble is on");
406  else if (getStatus(Cable)) strcat(statusOutput, "Cable - Rumble is off");
407  else if (getStatus(BluetoothRumble)) strcat(statusOutput, "Bluetooth - Rumble is on");
408  else if (getStatus(Bluetooth)) strcat(statusOutput, "Bluetooth - Rumble is off");
409  else strcat(statusOutput, "Error");
410 
411  return statusOutput;
412  } else
413  return "Error";
414 }
415 
416 /* Playstation Sixaxis Dualshock and Navigation Controller commands */
417 void PS3USB::PS3_Command(uint8_t* data, uint16_t nbytes) {
418  //bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x01), Report Type (Output 0x02), interface (0x00), datalength, datalength, data)
419  pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x01, 0x02, 0x00, nbytes, nbytes, data, NULL);
420 }
421 
423  for (uint8_t i = 0; i < PS3_REPORT_BUFFER_SIZE; i++)
424  writeBuf[i] = pgm_read_byte(&PS3_REPORT_BUFFER[i]); // Reset buffer
425 
426  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
427 }
428 
430  writeBuf[1] = 0x00;
431  writeBuf[2] = 0x00; //low mode off
432  writeBuf[3] = 0x00;
433  writeBuf[4] = 0x00; //high mode off
434 
435  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
436 }
437 
439  if ((mode & 0x30) > 0x00) {
440  uint8_t power[2] = {0xff, 0x00}; // Defaults to RumbleLow
441  if (mode == RumbleHigh) {
442  power[0] = 0x00;
443  power[1] = 0xff;
444  }
445  setRumbleOn(0xfe, power[0], 0xfe, power[1]);
446  }
447 }
448 
449 void PS3USB::setRumbleOn(uint8_t rightDuration, uint8_t rightPower, uint8_t leftDuration, uint8_t leftPower) {
450  writeBuf[1] = rightDuration;
451  writeBuf[2] = rightPower;
452  writeBuf[3] = leftDuration;
453  writeBuf[4] = leftPower;
454  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
455 }
456 
457 void PS3USB::setLedRaw(uint8_t value) {
458  writeBuf[9] = value << 1;
459  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
460 }
461 
463  writeBuf[9] &= ~((uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1));
464  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
465 }
466 
468  writeBuf[9] |= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
469  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
470 }
471 
473  writeBuf[9] ^= (uint8_t)((pgm_read_byte(&LEDS[(uint8_t)a]) & 0x0f) << 1);
474  PS3_Command(writeBuf, PS3_REPORT_BUFFER_SIZE);
475 }
476 
477 void PS3USB::setBdaddr(uint8_t* BDADDR) {
478  /* Set the internal bluetooth address */
479  uint8_t buf[8];
480  buf[0] = 0x01;
481  buf[1] = 0x00;
482  for (uint8_t i = 0; i < 6; i++)
483  buf[i + 2] = BDADDR[5 - i]; //Copy into buffer, has to be written reversed
484 
485  //bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF5), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
486  pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF5, 0x03, 0x00, 8, 8, buf, NULL);
487 }
488 
489 void PS3USB::enable_sixaxis() { //Command used to enable the Dualshock 3 and Navigation controller to send data via USB
490  uint8_t cmd_buf[4];
491  cmd_buf[0] = 0x42; // Special PS3 Controller enable commands
492  cmd_buf[1] = 0x0c;
493  cmd_buf[2] = 0x00;
494  cmd_buf[3] = 0x00;
495 
496  //bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0xF4), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
497  pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0xF4, 0x03, 0x00, 4, 4, cmd_buf, NULL);
498 }
499 
500 /* Playstation Move Controller commands */
501 void PS3USB::Move_Command(uint8_t* data, uint16_t nbytes) {
502  pUsb->outTransfer(bAddress, epInfo[ PS3_OUTPUT_PIPE ].epAddr, nbytes, data);
503 }
504 
505 void PS3USB::moveSetBulb(uint8_t r, uint8_t g, uint8_t b) { //Use this to set the Color using RGB values
506  // set the Bulb's values into the write buffer
507  writeBuf[2] = r;
508  writeBuf[3] = g;
509  writeBuf[4] = b;
510 
511  Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE);
512 }
513 
514 void PS3USB::moveSetBulb(Colors color) { //Use this to set the Color using the predefined colors in "enums.h"
515  moveSetBulb((uint8_t)(color >> 16), (uint8_t)(color >> 8), (uint8_t)(color));
516 }
517 
518 void PS3USB::moveSetRumble(uint8_t rumble) {
519 #ifdef DEBUG_USB_HOST
520  if (rumble < 64 && rumble != 0) // The rumble value has to at least 64, or approximately 25% (64/255*100)
521  Notify(PSTR("\r\nThe rumble value has to at least 64, or approximately 25%"), 0x80);
522 #endif
523  //set the rumble value into the write buffer
524  writeBuf[6] = rumble;
525 
526  Move_Command(writeBuf, MOVE_REPORT_BUFFER_SIZE);
527 }
528 
529 void PS3USB::setMoveBdaddr(uint8_t* BDADDR) {
530  /* Set the internal bluetooth address */
531  uint8_t buf[11];
532  buf[0] = 0x05;
533  buf[7] = 0x10;
534  buf[8] = 0x01;
535  buf[9] = 0x02;
536  buf[10] = 0x12;
537 
538  for (uint8_t i = 0; i < 6; i++)
539  buf[i + 1] = BDADDR[i];
540 
541  //bmRequest = Host to device (0x00) | Class (0x20) | Interface (0x01) = 0x21, bRequest = Set Report (0x09), Report ID (0x05), Report Type (Feature 0x03), interface (0x00), datalength, datalength, data)
542  pUsb->ctrlReq(bAddress, epInfo[PS3_CONTROL_PIPE].epAddr, bmREQ_HID_OUT, HID_REQUEST_SET_REPORT, 0x05, 0x03, 0x00, 11, 11, buf, NULL);
543 }
544 
545 void PS3USB::onInit() {
546  if (pFuncOnInit)
547  pFuncOnInit(); // Call the user function
548  else {
549  if (PS3MoveConnected)
550  moveSetBulb(Red);
551  else // Dualshock 3 or Navigation controller
552  setLedOn(LED1);
553  }
554 }
uint8_t bmRcvToggle
Definition: address.h:41
uint16_t getSensor(Sensor a)
Definition: PS3USB.cpp:341
Definition: PS3Enums.h:117
EpInfo * epinfo
Definition: address.h:76
bool lowspeed
Definition: address.h:79
#define USB_ERROR_EPINFO_IS_NULL
Definition: UsbCore.h:67
uint8_t bmNakPower
Definition: address.h:42
void setLedRaw(uint8_t value)
Definition: PS3USB.cpp:457
bool PS3NavigationConnected
Definition: PS3USB.h:246
#define PS3_INPUT_PIPE
Definition: PS3USB.h:33
Definition: PS3Enums.h:192
Sensor
Definition: PS3Enums.h:141
#define PS3MOVE_PID
Definition: BTD.h:27
const uint8_t PS3_REPORT_BUFFER[]
Definition: PS3Enums.h:24
virtual uint8_t Release()
Definition: PS3USB.cpp:258
#define PS3_OUTPUT_PIPE
Definition: PS3USB.h:32
#define NotifyFail(...)
Definition: message.h:55
bool PS3MoveConnected
Definition: PS3USB.h:244
Definition: PS3Enums.h:193
Definition: PS3Enums.h:194
const uint8_t LEDS[]
Definition: PS3Enums.h:43
const uint8_t ANALOGBUTTONS[]
Definition: PS3Enums.h:93
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value)
Definition: Usb.cpp:795
uint8_t getAnalogButton(Button a)
Definition: PS3USB.cpp:329
#define PS3_VID
Definition: BTD.h:24
#define NotifyFailGetDevDescr(...)
Definition: message.h:50
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo *eprecord_ptr)
Definition: Usb.cpp:64
void setRumbleOff()
Definition: PS3USB.cpp:429
#define EP_MAXPKTSIZE
Definition: PS3USB.h:25
bool PS3Connected
Definition: PS3USB.h:238
virtual void FreeAddress(uint8_t addr)=0
String getStatusString()
Definition: PS3USB.cpp:381
uint8_t epAttribs
Definition: address.h:37
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)
Definition: Usb.cpp:126
virtual UsbDevice * GetUsbDevicePtr(uint8_t addr)=0
bool getStatus(Status c)
Definition: PS3USB.cpp:373
bool getButtonClick(Button b)
Definition: PS3USB.cpp:322
#define Notify(...)
Definition: message.h:44
#define PS3_CONTROL_PIPE
Definition: PS3USB.h:31
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:790
void setRumbleOn(Rumble mode)
Definition: PS3USB.cpp:438
uint8_t epAddr
Definition: address.h:33
void setBdaddr(uint8_t *BDADDR)
Definition: PS3USB.cpp:477
Definition: PS3Enums.h:147
#define NotifyFailUnknownDevice(...)
Definition: message.h:54
Status
Definition: PS3Enums.h:182
Colors
Definition: PS3Enums.h:115
#define USB_NAK_MAX_POWER
Definition: address.h:27
void moveSetBulb(uint8_t r, uint8_t g, uint8_t b)
Definition: PS3USB.cpp:505
void setLedToggle(LED a)
Definition: PS3USB.cpp:472
Rumble
Definition: PS3Enums.h:210
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: PS3USB.cpp:46
#define EP_INTERRUPT
Definition: PS3USB.h:28
Definition: address.h:32
#define MOVE_REPORT_BUFFER_SIZE
Definition: PS3Enums.h:40
void setAllOff()
Definition: PS3USB.cpp:422
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:290
#define HID_REQUEST_SET_REPORT
Definition: BTD.h:39
void setMoveBdaddr(uint8_t *BDADDR)
Definition: PS3USB.cpp:529
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
uint8_t bmSndToggle
Definition: address.h:40
Definition: PS3Enums.h:143
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
Definition: UsbCore.h:69
Angle
Definition: PS3Enums.h:177
USB * pUsb
Definition: PS3USB.h:250
#define USB_NAK_NOWAIT
Definition: address.h:29
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:66
#define PS3_PID
Definition: BTD.h:25
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data)
Definition: Usb.cpp:206
#define PS3NAVIGATION_PID
Definition: BTD.h:26
void moveSetRumble(uint8_t rumble)
Definition: PS3USB.cpp:518
virtual uint8_t Poll()
Definition: PS3USB.cpp:268
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
Definition: UsbCore.h:61
#define PS3_MAX_ENDPOINTS
Definition: PS3USB.h:45
EpInfo epInfo[PS3_MAX_ENDPOINTS]
Definition: PS3USB.h:254
#define bmRCVTOG0
Definition: max3421e.h:185
#define bmREQ_HID_OUT
Definition: BTD.h:38
#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
uint8_t bAddress
Definition: PS3USB.h:252
#define PS3_REPORT_BUFFER_SIZE
Definition: PS3Enums.h:37
Definition: UsbCore.h:152
uint8_t getAnalogHat(AnalogHat a)
Definition: PS3USB.cpp:335
double getAngle(Angle a)
Definition: PS3USB.cpp:347
void setLedOn(LED a)
Definition: PS3USB.cpp:467
uint8_t RegisterDeviceClass(USBDeviceConfig *pdev)
Definition: UsbCore.h:172
#define NotifyFailSetConfDescr(...)
Definition: message.h:53
bool getButtonPress(Button b)
Definition: PS3USB.cpp:318
AnalogHat
const uint32_t BUTTONS[]
Definition: PS3Enums.h:62
PS3USB(USB *pUsb, uint8_t btadr5=0, uint8_t btadr4=0, uint8_t btadr3=0, uint8_t btadr2=0, uint8_t btadr1=0, uint8_t btadr0=0)
Definition: PS3USB.cpp:23
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:756
Definition: PS3Enums.h:145
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:51
void setLedOff(LED a)
Definition: PS3USB.cpp:462