From 8092bb3aa16303815522e7b47461215c10420636 Mon Sep 17 00:00:00 2001 From: "Deployment Bot (from Travis CI)" Date: Fri, 18 Jan 2019 00:43:00 +0000 Subject: [PATCH] Deploy felis/USB_Host_Shield_2.0 to github.com/felis/USB_Host_Shield_2.0.git:gh-pages --- _x_b_o_x_o_n_e_8cpp_source.html | 502 ++++++++++++++++---------------- _x_b_o_x_o_n_e_8h_source.html | 16 +- class_x_b_o_x_o_n_e.html | 16 +- 3 files changed, 270 insertions(+), 264 deletions(-) diff --git a/_x_b_o_x_o_n_e_8cpp_source.html b/_x_b_o_x_o_n_e_8cpp_source.html index 123a47ec..d7b260ed 100644 --- a/_x_b_o_x_o_n_e_8cpp_source.html +++ b/_x_b_o_x_o_n_e_8cpp_source.html @@ -323,252 +323,260 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
236 }
237 
238 /* Extracts endpoint information from config descriptor */
-
239 void XBOXONE::EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *pep) {
-
240  bConfNum = conf;
-
241  uint8_t index;
-
242 
-
243  if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT) { // Interrupt endpoint
-
244  index = (pep->bEndpointAddress & 0x80) == 0x80 ? XBOX_ONE_INPUT_PIPE : XBOX_ONE_OUTPUT_PIPE; // Set the endpoint index
-
245  } else
-
246  return;
-
247 
-
248  // Fill the rest of endpoint data structure
-
249  epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F);
-
250  epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize;
-
251 #ifdef EXTRADEBUG
-
252  PrintEndpointDescriptor(pep);
-
253 #endif
-
254  if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints
-
255  pollInterval = pep->bInterval;
-
256  bNumEP++;
-
257 }
-
258 
-
259 void XBOXONE::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr) {
-
260 #ifdef EXTRADEBUG
-
261  Notify(PSTR("\r\nEndpoint descriptor:"), 0x80);
-
262  Notify(PSTR("\r\nLength:\t\t"), 0x80);
-
263  D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
-
264  Notify(PSTR("\r\nType:\t\t"), 0x80);
-
265  D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
-
266  Notify(PSTR("\r\nAddress:\t"), 0x80);
-
267  D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
-
268  Notify(PSTR("\r\nAttributes:\t"), 0x80);
-
269  D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
-
270  Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
-
271  D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
-
272  Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
-
273  D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
-
274 #endif
-
275 }
-
276 
-
277 /* Performs a cleanup after failed Init() attempt */
-
278 uint8_t XBOXONE::Release() {
-
279  XboxOneConnected = false;
-
280  pUsb->GetAddressPool().FreeAddress(bAddress);
-
281  bAddress = 0; // Clear device address
-
282  bNumEP = 1; // Must have to be reset to 1
-
283  qNextPollTime = 0; // Reset next poll time
-
284  pollInterval = 0;
-
285  bPollEnable = false;
-
286 #ifdef DEBUG_USB_HOST
-
287  Notify(PSTR("\r\nXbox One Controller Disconnected\r\n"), 0x80);
-
288 #endif
-
289  return 0;
-
290 }
-
291 
-
292 uint8_t XBOXONE::Poll() {
-
293  uint8_t rcode = 0;
-
294 
-
295  if(!bPollEnable)
-
296  return 0;
-
297 
-
298  if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) { // Do not poll if shorter than polling interval
-
299  qNextPollTime = (uint32_t)millis() + pollInterval; // Set new poll time
-
300  uint16_t length = (uint16_t)epInfo[ XBOX_ONE_INPUT_PIPE ].maxPktSize; // Read the maximum packet size from the endpoint
-
301  uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ XBOX_ONE_INPUT_PIPE ].epAddr, &length, readBuf, pollInterval);
-
302  if(!rcode) {
-
303  readReport();
-
304 #ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the Xbox ONE Controller
-
305  for(uint8_t i = 0; i < length; i++) {
-
306  D_PrintHex<uint8_t > (readBuf[i], 0x80);
-
307  Notify(PSTR(" "), 0x80);
-
308  }
-
309  Notify(PSTR("\r\n"), 0x80);
-
310 #endif
-
311  }
-
312 #ifdef DEBUG_USB_HOST
-
313  else if(rcode != hrNAK) { // Not a matter of no update to send
-
314  Notify(PSTR("\r\nXbox One Poll Failed, error code: "), 0x80);
-
315  NotifyFail(rcode);
-
316  }
-
317 #endif
-
318  }
-
319  return rcode;
-
320 }
-
321 
-
322 void XBOXONE::readReport() {
-
323  if(readBuf[0] == 0x07) {
-
324  // The XBOX button has a separate message
-
325  if(readBuf[4] == 1)
-
326  ButtonState |= pgm_read_word(&XBOX_BUTTONS[XBOX]);
-
327  else
-
328  ButtonState &= ~pgm_read_word(&XBOX_BUTTONS[XBOX]);
+
239 void XBOXONE::EndpointXtract(uint8_t conf,
+
240  uint8_t iface __attribute__((unused)),
+
241  uint8_t alt __attribute__((unused)),
+
242  uint8_t proto __attribute__((unused)),
+
243  const USB_ENDPOINT_DESCRIPTOR *pep)
+
244 {
+
245 
+
246  bConfNum = conf;
+
247  uint8_t index;
+
248 
+
249  if((pep->bmAttributes & bmUSB_TRANSFER_TYPE) == USB_TRANSFER_TYPE_INTERRUPT) { // Interrupt endpoint
+
250  index = (pep->bEndpointAddress & 0x80) == 0x80 ? XBOX_ONE_INPUT_PIPE : XBOX_ONE_OUTPUT_PIPE; // Set the endpoint index
+
251  } else
+
252  return;
+
253 
+
254  // Fill the rest of endpoint data structure
+
255  epInfo[index].epAddr = (pep->bEndpointAddress & 0x0F);
+
256  epInfo[index].maxPktSize = (uint8_t)pep->wMaxPacketSize;
+
257 #ifdef EXTRADEBUG
+
258  PrintEndpointDescriptor(pep);
+
259 #endif
+
260  if(pollInterval < pep->bInterval) // Set the polling interval as the largest polling interval obtained from endpoints
+
261  pollInterval = pep->bInterval;
+
262  bNumEP++;
+
263 }
+
264 
+
265 void XBOXONE::PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR* ep_ptr
+
266  __attribute__((unused)))
+
267 {
+
268 #ifdef EXTRADEBUG
+
269  Notify(PSTR("\r\nEndpoint descriptor:"), 0x80);
+
270  Notify(PSTR("\r\nLength:\t\t"), 0x80);
+
271  D_PrintHex<uint8_t > (ep_ptr->bLength, 0x80);
+
272  Notify(PSTR("\r\nType:\t\t"), 0x80);
+
273  D_PrintHex<uint8_t > (ep_ptr->bDescriptorType, 0x80);
+
274  Notify(PSTR("\r\nAddress:\t"), 0x80);
+
275  D_PrintHex<uint8_t > (ep_ptr->bEndpointAddress, 0x80);
+
276  Notify(PSTR("\r\nAttributes:\t"), 0x80);
+
277  D_PrintHex<uint8_t > (ep_ptr->bmAttributes, 0x80);
+
278  Notify(PSTR("\r\nMaxPktSize:\t"), 0x80);
+
279  D_PrintHex<uint16_t > (ep_ptr->wMaxPacketSize, 0x80);
+
280  Notify(PSTR("\r\nPoll Intrv:\t"), 0x80);
+
281  D_PrintHex<uint8_t > (ep_ptr->bInterval, 0x80);
+
282 #endif
+
283 }
+
284 
+
285 /* Performs a cleanup after failed Init() attempt */
+
286 uint8_t XBOXONE::Release() {
+
287  XboxOneConnected = false;
+
288  pUsb->GetAddressPool().FreeAddress(bAddress);
+
289  bAddress = 0; // Clear device address
+
290  bNumEP = 1; // Must have to be reset to 1
+
291  qNextPollTime = 0; // Reset next poll time
+
292  pollInterval = 0;
+
293  bPollEnable = false;
+
294 #ifdef DEBUG_USB_HOST
+
295  Notify(PSTR("\r\nXbox One Controller Disconnected\r\n"), 0x80);
+
296 #endif
+
297  return 0;
+
298 }
+
299 
+
300 uint8_t XBOXONE::Poll() {
+
301  uint8_t rcode = 0;
+
302 
+
303  if(!bPollEnable)
+
304  return 0;
+
305 
+
306  if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) { // Do not poll if shorter than polling interval
+
307  qNextPollTime = (uint32_t)millis() + pollInterval; // Set new poll time
+
308  uint16_t length = (uint16_t)epInfo[ XBOX_ONE_INPUT_PIPE ].maxPktSize; // Read the maximum packet size from the endpoint
+
309  uint8_t rcode = pUsb->inTransfer(bAddress, epInfo[ XBOX_ONE_INPUT_PIPE ].epAddr, &length, readBuf, pollInterval);
+
310  if(!rcode) {
+
311  readReport();
+
312 #ifdef PRINTREPORT // Uncomment "#define PRINTREPORT" to print the report send by the Xbox ONE Controller
+
313  for(uint8_t i = 0; i < length; i++) {
+
314  D_PrintHex<uint8_t > (readBuf[i], 0x80);
+
315  Notify(PSTR(" "), 0x80);
+
316  }
+
317  Notify(PSTR("\r\n"), 0x80);
+
318 #endif
+
319  }
+
320 #ifdef DEBUG_USB_HOST
+
321  else if(rcode != hrNAK) { // Not a matter of no update to send
+
322  Notify(PSTR("\r\nXbox One Poll Failed, error code: "), 0x80);
+
323  NotifyFail(rcode);
+
324  }
+
325 #endif
+
326  }
+
327  return rcode;
+
328 }
329 
-
330  if(ButtonState != OldButtonState) {
-
331  ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
-
332  OldButtonState = ButtonState;
-
333  }
-
334  }
-
335  if(readBuf[0] != 0x20) { // Check if it's the correct report, otherwise return - the controller also sends different status reports
-
336 #ifdef EXTRADEBUG
-
337  Notify(PSTR("\r\nXbox Poll: "), 0x80);
-
338  D_PrintHex<uint8_t > (readBuf[0], 0x80); // 0x03 is a heart beat report!
-
339 #endif
-
340  return;
-
341  }
-
342 
-
343  uint16_t xbox = ButtonState & pgm_read_word(&XBOX_BUTTONS[XBOX]); // Since the XBOX button is separate, save it and add it back in
-
344  // xbox button from before, dpad, abxy, start/back, sync, stick click, shoulder buttons
-
345  ButtonState = xbox | (((uint16_t)readBuf[5] & 0xF) << 8) | (readBuf[4] & 0xF0) | (((uint16_t)readBuf[4] & 0x0C) << 10) | ((readBuf[4] & 0x01) << 3) | (((uint16_t)readBuf[5] & 0xC0) << 8) | ((readBuf[5] & 0x30) >> 4);
-
346 
-
347  triggerValue[0] = (uint16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]);
-
348  triggerValue[1] = (uint16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]);
-
349 
-
350  hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
-
351  hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
-
352  hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]);
-
353  hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]);
+
330 void XBOXONE::readReport() {
+
331  if(readBuf[0] == 0x07) {
+
332  // The XBOX button has a separate message
+
333  if(readBuf[4] == 1)
+
334  ButtonState |= pgm_read_word(&XBOX_BUTTONS[XBOX]);
+
335  else
+
336  ButtonState &= ~pgm_read_word(&XBOX_BUTTONS[XBOX]);
+
337 
+
338  if(ButtonState != OldButtonState) {
+
339  ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
+
340  OldButtonState = ButtonState;
+
341  }
+
342  }
+
343  if(readBuf[0] != 0x20) { // Check if it's the correct report, otherwise return - the controller also sends different status reports
+
344 #ifdef EXTRADEBUG
+
345  Notify(PSTR("\r\nXbox Poll: "), 0x80);
+
346  D_PrintHex<uint8_t > (readBuf[0], 0x80); // 0x03 is a heart beat report!
+
347 #endif
+
348  return;
+
349  }
+
350 
+
351  uint16_t xbox = ButtonState & pgm_read_word(&XBOX_BUTTONS[XBOX]); // Since the XBOX button is separate, save it and add it back in
+
352  // xbox button from before, dpad, abxy, start/back, sync, stick click, shoulder buttons
+
353  ButtonState = xbox | (((uint16_t)readBuf[5] & 0xF) << 8) | (readBuf[4] & 0xF0) | (((uint16_t)readBuf[4] & 0x0C) << 10) | ((readBuf[4] & 0x01) << 3) | (((uint16_t)readBuf[5] & 0xC0) << 8) | ((readBuf[5] & 0x30) >> 4);
354 
-
355  //Notify(PSTR("\r\nButtonState"), 0x80);
-
356  //PrintHex<uint16_t>(ButtonState, 0x80);
+
355  triggerValue[0] = (uint16_t)(((uint16_t)readBuf[7] << 8) | readBuf[6]);
+
356  triggerValue[1] = (uint16_t)(((uint16_t)readBuf[9] << 8) | readBuf[8]);
357 
-
358  if(ButtonState != OldButtonState) {
-
359  ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
-
360  OldButtonState = ButtonState;
-
361  }
+
358  hatValue[LeftHatX] = (int16_t)(((uint16_t)readBuf[11] << 8) | readBuf[10]);
+
359  hatValue[LeftHatY] = (int16_t)(((uint16_t)readBuf[13] << 8) | readBuf[12]);
+
360  hatValue[RightHatX] = (int16_t)(((uint16_t)readBuf[15] << 8) | readBuf[14]);
+
361  hatValue[RightHatY] = (int16_t)(((uint16_t)readBuf[17] << 8) | readBuf[16]);
362 
-
363  // Handle click detection for triggers
-
364  if(triggerValue[0] != 0 && triggerValueOld[0] == 0)
-
365  L2Clicked = true;
-
366  triggerValueOld[0] = triggerValue[0];
-
367  if(triggerValue[1] != 0 && triggerValueOld[1] == 0)
-
368  R2Clicked = true;
-
369  triggerValueOld[1] = triggerValue[1];
-
370 }
-
371 
-
372 uint16_t XBOXONE::getButtonPress(ButtonEnum b) {
-
373  if(b == L2) // These are analog buttons
-
374  return triggerValue[0];
-
375  else if(b == R2)
-
376  return triggerValue[1];
-
377  return (bool)(ButtonState & ((uint16_t)pgm_read_word(&XBOX_BUTTONS[(uint8_t)b])));
+
363  //Notify(PSTR("\r\nButtonState"), 0x80);
+
364  //PrintHex<uint16_t>(ButtonState, 0x80);
+
365 
+
366  if(ButtonState != OldButtonState) {
+
367  ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
+
368  OldButtonState = ButtonState;
+
369  }
+
370 
+
371  // Handle click detection for triggers
+
372  if(triggerValue[0] != 0 && triggerValueOld[0] == 0)
+
373  L2Clicked = true;
+
374  triggerValueOld[0] = triggerValue[0];
+
375  if(triggerValue[1] != 0 && triggerValueOld[1] == 0)
+
376  R2Clicked = true;
+
377  triggerValueOld[1] = triggerValue[1];
378 }
379 
-
380 bool XBOXONE::getButtonClick(ButtonEnum b) {
-
381  if(b == L2) {
-
382  if(L2Clicked) {
-
383  L2Clicked = false;
-
384  return true;
-
385  }
-
386  return false;
-
387  } else if(b == R2) {
-
388  if(R2Clicked) {
-
389  R2Clicked = false;
-
390  return true;
-
391  }
-
392  return false;
-
393  }
-
394  uint16_t button = pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]);
-
395  bool click = (ButtonClickState & button);
-
396  ButtonClickState &= ~button; // Clear "click" event
-
397  return click;
-
398 }
-
399 
-
400 int16_t XBOXONE::getAnalogHat(AnalogHatEnum a) {
-
401  return hatValue[a];
-
402 }
-
403 
-
404 /* Xbox Controller commands */
-
405 uint8_t XBOXONE::XboxCommand(uint8_t* data, uint16_t nbytes) {
-
406  data[2] = cmdCounter++; // Increment the output command counter
-
407  uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ XBOX_ONE_OUTPUT_PIPE ].epAddr, nbytes, data);
-
408 #ifdef DEBUG_USB_HOST
-
409  Notify(PSTR("\r\nXboxCommand, Return: "), 0x80);
-
410  D_PrintHex<uint8_t > (rcode, 0x80);
-
411 #endif
-
412  return rcode;
-
413 }
-
414 
-
415 // The Xbox One packets are described at: https://github.com/quantus/xbox-one-controller-protocol
-
416 void XBOXONE::onInit() {
-
417  // A short buzz to show the controller is active
-
418  uint8_t writeBuf[13];
-
419 
-
420  // Activate rumble
-
421  writeBuf[0] = 0x09;
-
422  writeBuf[1] = 0x00;
-
423  // Byte 2 is set in "XboxCommand"
-
424 
-
425  // Single rumble effect
-
426  writeBuf[3] = 0x09; // Substructure (what substructure rest of this packet has)
-
427  writeBuf[4] = 0x00; // Mode
-
428  writeBuf[5] = 0x0F; // Rumble mask (what motors are activated) (0000 lT rT L R)
-
429  writeBuf[6] = 0x04; // lT force
-
430  writeBuf[7] = 0x04; // rT force
-
431  writeBuf[8] = 0x20; // L force
-
432  writeBuf[9] = 0x20; // R force
-
433  writeBuf[10] = 0x80; // Length of pulse
-
434  writeBuf[11] = 0x00; // Off period
-
435  writeBuf[12] = 0x00; // Repeat count
-
436  XboxCommand(writeBuf, 13);
-
437 
-
438  if(pFuncOnInit)
-
439  pFuncOnInit(); // Call the user function
-
440 }
-
441 
-
442 void XBOXONE::setRumbleOff() {
-
443  uint8_t writeBuf[13];
-
444 
-
445  // Activate rumble
-
446  writeBuf[0] = 0x09;
-
447  writeBuf[1] = 0x00;
-
448  // Byte 2 is set in "XboxCommand"
+
380 uint16_t XBOXONE::getButtonPress(ButtonEnum b) {
+
381  if(b == L2) // These are analog buttons
+
382  return triggerValue[0];
+
383  else if(b == R2)
+
384  return triggerValue[1];
+
385  return (bool)(ButtonState & ((uint16_t)pgm_read_word(&XBOX_BUTTONS[(uint8_t)b])));
+
386 }
+
387 
+
388 bool XBOXONE::getButtonClick(ButtonEnum b) {
+
389  if(b == L2) {
+
390  if(L2Clicked) {
+
391  L2Clicked = false;
+
392  return true;
+
393  }
+
394  return false;
+
395  } else if(b == R2) {
+
396  if(R2Clicked) {
+
397  R2Clicked = false;
+
398  return true;
+
399  }
+
400  return false;
+
401  }
+
402  uint16_t button = pgm_read_word(&XBOX_BUTTONS[(uint8_t)b]);
+
403  bool click = (ButtonClickState & button);
+
404  ButtonClickState &= ~button; // Clear "click" event
+
405  return click;
+
406 }
+
407 
+
408 int16_t XBOXONE::getAnalogHat(AnalogHatEnum a) {
+
409  return hatValue[a];
+
410 }
+
411 
+
412 /* Xbox Controller commands */
+
413 uint8_t XBOXONE::XboxCommand(uint8_t* data, uint16_t nbytes) {
+
414  data[2] = cmdCounter++; // Increment the output command counter
+
415  uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ XBOX_ONE_OUTPUT_PIPE ].epAddr, nbytes, data);
+
416 #ifdef DEBUG_USB_HOST
+
417  Notify(PSTR("\r\nXboxCommand, Return: "), 0x80);
+
418  D_PrintHex<uint8_t > (rcode, 0x80);
+
419 #endif
+
420  return rcode;
+
421 }
+
422 
+
423 // The Xbox One packets are described at: https://github.com/quantus/xbox-one-controller-protocol
+
424 void XBOXONE::onInit() {
+
425  // A short buzz to show the controller is active
+
426  uint8_t writeBuf[13];
+
427 
+
428  // Activate rumble
+
429  writeBuf[0] = 0x09;
+
430  writeBuf[1] = 0x00;
+
431  // Byte 2 is set in "XboxCommand"
+
432 
+
433  // Single rumble effect
+
434  writeBuf[3] = 0x09; // Substructure (what substructure rest of this packet has)
+
435  writeBuf[4] = 0x00; // Mode
+
436  writeBuf[5] = 0x0F; // Rumble mask (what motors are activated) (0000 lT rT L R)
+
437  writeBuf[6] = 0x04; // lT force
+
438  writeBuf[7] = 0x04; // rT force
+
439  writeBuf[8] = 0x20; // L force
+
440  writeBuf[9] = 0x20; // R force
+
441  writeBuf[10] = 0x80; // Length of pulse
+
442  writeBuf[11] = 0x00; // Off period
+
443  writeBuf[12] = 0x00; // Repeat count
+
444  XboxCommand(writeBuf, 13);
+
445 
+
446  if(pFuncOnInit)
+
447  pFuncOnInit(); // Call the user function
+
448 }
449 
-
450  // Continuous rumble effect
-
451  writeBuf[3] = 0x09; // Substructure (what substructure rest of this packet has)
-
452  writeBuf[4] = 0x00; // Mode
-
453  writeBuf[5] = 0x0F; // Rumble mask (what motors are activated) (0000 lT rT L R)
-
454  writeBuf[6] = 0x00; // lT force
-
455  writeBuf[7] = 0x00; // rT force
-
456  writeBuf[8] = 0x00; // L force
-
457  writeBuf[9] = 0x00; // R force
-
458  writeBuf[10] = 0x00; // On period
-
459  writeBuf[11] = 0x00; // Off period
-
460  writeBuf[12] = 0x00; // Repeat count
-
461  XboxCommand(writeBuf, 13);
-
462 }
-
463 
-
464 void XBOXONE::setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor) {
-
465  uint8_t writeBuf[13];
-
466 
-
467  // Activate rumble
-
468  writeBuf[0] = 0x09;
-
469  writeBuf[1] = 0x00;
-
470  // Byte 2 is set in "XboxCommand"
+
450 void XBOXONE::setRumbleOff() {
+
451  uint8_t writeBuf[13];
+
452 
+
453  // Activate rumble
+
454  writeBuf[0] = 0x09;
+
455  writeBuf[1] = 0x00;
+
456  // Byte 2 is set in "XboxCommand"
+
457 
+
458  // Continuous rumble effect
+
459  writeBuf[3] = 0x09; // Substructure (what substructure rest of this packet has)
+
460  writeBuf[4] = 0x00; // Mode
+
461  writeBuf[5] = 0x0F; // Rumble mask (what motors are activated) (0000 lT rT L R)
+
462  writeBuf[6] = 0x00; // lT force
+
463  writeBuf[7] = 0x00; // rT force
+
464  writeBuf[8] = 0x00; // L force
+
465  writeBuf[9] = 0x00; // R force
+
466  writeBuf[10] = 0x00; // On period
+
467  writeBuf[11] = 0x00; // Off period
+
468  writeBuf[12] = 0x00; // Repeat count
+
469  XboxCommand(writeBuf, 13);
+
470 }
471 
-
472  // Continuous rumble effect
-
473  writeBuf[3] = 0x09; // Substructure (what substructure rest of this packet has)
-
474  writeBuf[4] = 0x00; // Mode
-
475  writeBuf[5] = 0x0F; // Rumble mask (what motors are activated) (0000 lT rT L R)
-
476  writeBuf[6] = leftTrigger; // lT force
-
477  writeBuf[7] = rightTrigger; // rT force
-
478  writeBuf[8] = leftMotor; // L force
-
479  writeBuf[9] = rightMotor; // R force
-
480  writeBuf[10] = 0xFF; // On period
-
481  writeBuf[11] = 0x00; // Off period
-
482  writeBuf[12] = 0xFF; // Repeat count
-
483  XboxCommand(writeBuf, 13);
-
484 }
+
472 void XBOXONE::setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor) {
+
473  uint8_t writeBuf[13];
+
474 
+
475  // Activate rumble
+
476  writeBuf[0] = 0x09;
+
477  writeBuf[1] = 0x00;
+
478  // Byte 2 is set in "XboxCommand"
+
479 
+
480  // Continuous rumble effect
+
481  writeBuf[3] = 0x09; // Substructure (what substructure rest of this packet has)
+
482  writeBuf[4] = 0x00; // Mode
+
483  writeBuf[5] = 0x0F; // Rumble mask (what motors are activated) (0000 lT rT L R)
+
484  writeBuf[6] = leftTrigger; // lT force
+
485  writeBuf[7] = rightTrigger; // rT force
+
486  writeBuf[8] = leftMotor; // L force
+
487  writeBuf[9] = rightMotor; // R force
+
488  writeBuf[10] = 0xFF; // On period
+
489  writeBuf[11] = 0x00; // Off period
+
490  writeBuf[12] = 0xFF; // Repeat count
+
491  XboxCommand(writeBuf, 13);
+
492 }
uint8_t bConfNum
Definition: XBOXONE.h:186
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr)
Definition: Usb.cpp:801
uint8_t bmRcvToggle
Definition: address.h:48
@@ -582,7 +590,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define pgm_read_word(addr)
Definition: usb_ch9.h:148
uint8_t bInterval
Definition: usb_ch9.h:154
-
uint8_t bLength
Definition: usb_ch9.h:149
USB * pUsb
Definition: XBOXONE.h:179
#define NotifyFail(...)
Definition: message.h:62
AnalogHatEnum
@@ -602,14 +609,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define USBTRACE2(s, r)
Definition: macros.h:84
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr)
Definition: Usb.cpp:831
#define NotifyFailGetConfDescr(...)
Definition: message.h:59
-
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
Definition: XBOXONE.cpp:259
+
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
Definition: XBOXONE.cpp:265
uint8_t epAddr
Definition: address.h:40
bool XboxOneConnected
Definition: XBOXONE.h:175
#define XBOX_ONE_MAX_ENDPOINTS
Definition: XBOXONE.h:37
#define NotifyFailUnknownDevice(...)
Definition: message.h:61
-
void setRumbleOff()
Definition: XBOXONE.cpp:442
+
void setRumbleOff()
Definition: XBOXONE.cpp:450
#define USB_NAK_MAX_POWER
Definition: address.h:34
-
virtual uint8_t Release()
Definition: XBOXONE.cpp:278
+
virtual uint8_t Release()
Definition: XBOXONE.cpp:286
Definition: address.h:39
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data)
Definition: Usb.cpp:303
@@ -618,7 +625,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
uint16_t wMaxPacketSize
Definition: usb_ch9.h:153
#define bmUSB_TRANSFER_TYPE
Definition: usb_ch9.h:94
-
uint16_t getButtonPress(ButtonEnum b)
Definition: XBOXONE.cpp:372
+
uint16_t getButtonPress(ButtonEnum b)
Definition: XBOXONE.cpp:380
uint32_t qNextPollTime
Definition: XBOXONE.h:190
virtual uint8_t AllocAddress(uint8_t parent, bool is_hub=false, uint8_t port=0)=0
@@ -627,11 +634,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define USB_ERROR_CLASS_INSTANCE_ALREADY_IN_USE
Definition: UsbCore.h:98
#define PSTR(str)
#define XBOX_ONE_INPUT_PIPE
Definition: XBOXONE.h:35
-
uint8_t bDescriptorType
Definition: usb_ch9.h:150
EpInfo epInfo[XBOX_ONE_MAX_ENDPOINTS]
Definition: XBOXONE.h:183
-
bool getButtonClick(ButtonEnum b)
Definition: XBOXONE.cpp:380
-
virtual uint8_t Poll()
Definition: XBOXONE.cpp:292
+
bool getButtonClick(ButtonEnum b)
Definition: XBOXONE.cpp:388
+
virtual uint8_t Poll()
Definition: XBOXONE.cpp:300
#define USB_NAK_NOWAIT
Definition: address.h:36
#define USB_ERROR_ADDRESS_NOT_FOUND_IN_POOL
Definition: UsbCore.h:95
#define USB_DEV_CONFIG_ERROR_DEVICE_NOT_SUPPORTED
Definition: UsbCore.h:90
@@ -644,7 +650,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
#define XBOX_ONE_CONTROL_PIPE
Definition: XBOXONE.h:33
#define XBOX_ONE_OUTPUT_PIPE
Definition: XBOXONE.h:34
-
int16_t getAnalogHat(AnalogHatEnum a)
Definition: XBOXONE.cpp:400
+
int16_t getAnalogHat(AnalogHatEnum a)
Definition: XBOXONE.cpp:408
const uint16_t XBOX_BUTTONS[]
Definition: xboxEnums.h:41
@@ -654,7 +660,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid)
Definition: XBOXONE.h:124
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr)
defined(USB_METHODS_INLINE)
Definition: Usb.cpp:796
#define NotifyFailSetDevTblEntry(...)
Definition: message.h:58
-
void setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor)
Definition: XBOXONE.cpp:464
+
void setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor)
Definition: XBOXONE.cpp:472
Definition: usb_ch9.h:105
diff --git a/_x_b_o_x_o_n_e_8h_source.html b/_x_b_o_x_o_n_e_8h_source.html index ce5c77a6..aa911bc2 100644 --- a/_x_b_o_x_o_n_e_8h_source.html +++ b/_x_b_o_x_o_n_e_8h_source.html @@ -247,25 +247,25 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
void EndpointXtract(uint8_t conf, uint8_t iface, uint8_t alt, uint8_t proto, const USB_ENDPOINT_DESCRIPTOR *ep)
Definition: XBOXONE.cpp:239
uint8_t bNumEP
Definition: XBOXONE.h:188
#define XBOX_VID6
Definition: XBOXONE.h:54
-
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
Definition: XBOXONE.cpp:259
+
void PrintEndpointDescriptor(const USB_ENDPOINT_DESCRIPTOR *ep_ptr)
Definition: XBOXONE.cpp:265
bool XboxOneConnected
Definition: XBOXONE.h:175
#define XBOX_ONE_MAX_ENDPOINTS
Definition: XBOXONE.h:37
#define XBOX_VID2
Definition: XBOXONE.h:50
-
void setRumbleOff()
Definition: XBOXONE.cpp:442
+
void setRumbleOff()
Definition: XBOXONE.cpp:450
#define XBOX_ONE_PID8
Definition: XBOXONE.h:59
-
virtual uint8_t Release()
Definition: XBOXONE.cpp:278
+
virtual uint8_t Release()
Definition: XBOXONE.cpp:286
#define XBOX_VID4
Definition: XBOXONE.h:52
Definition: address.h:39
ButtonEnum
-
uint16_t getButtonPress(ButtonEnum b)
Definition: XBOXONE.cpp:372
+
uint16_t getButtonPress(ButtonEnum b)
Definition: XBOXONE.cpp:380
virtual uint8_t GetAddress()
Definition: XBOXONE.h:98
uint32_t qNextPollTime
Definition: XBOXONE.h:190
#define XBOX_ONE_PID2
Definition: XBOXONE.h:44
EpInfo epInfo[XBOX_ONE_MAX_ENDPOINTS]
Definition: XBOXONE.h:183
-
bool getButtonClick(ButtonEnum b)
Definition: XBOXONE.cpp:380
+
bool getButtonClick(ButtonEnum b)
Definition: XBOXONE.cpp:388
uint8_t readPollInterval()
Definition: XBOXONE.h:114
-
virtual uint8_t Poll()
Definition: XBOXONE.cpp:292
+
virtual uint8_t Poll()
Definition: XBOXONE.cpp:300
#define XBOX_ONE_PID11
Definition: XBOXONE.h:62
#define XBOX_ONE_PID4
Definition: XBOXONE.h:46
virtual uint8_t Init(uint8_t parent, uint8_t port, bool lowspeed)
Definition: XBOXONE.cpp:46
@@ -275,13 +275,13 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
Definition: UsbCore.h:210
#define XBOX_VID5
Definition: XBOXONE.h:53
#define XBOX_ONE_PID6
Definition: XBOXONE.h:57
-
int16_t getAnalogHat(AnalogHatEnum a)
Definition: XBOXONE.cpp:400
+
int16_t getAnalogHat(AnalogHatEnum a)
Definition: XBOXONE.cpp:408
#define XBOX_VID1
Definition: XBOXONE.h:42
Definition: XBOXONE.h:66
#define XBOX_ONE_PID1
Definition: XBOXONE.h:43
#define XBOX_ONE_PID3
Definition: XBOXONE.h:45
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid)
Definition: XBOXONE.h:124
-
void setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor)
Definition: XBOXONE.cpp:464
+
void setRumbleOn(uint8_t leftTrigger, uint8_t rightTrigger, uint8_t leftMotor, uint8_t rightMotor)
Definition: XBOXONE.cpp:472