@@ -437,9 +437,12 @@ Joystick_::Joystick_(
437
437
memcpy (customHidReportDescriptor, tempHidReportDescriptor, hidReportDescriptorSize);
438
438
439
439
// Register HID Report Description
440
+ #ifdef USE_TINYUSB
441
+ _usb_hid.setReportDescriptor (customHidReportDescriptor, hidReportDescriptorSize);
442
+ #else
440
443
DynamicHIDSubDescriptor *node = new DynamicHIDSubDescriptor (customHidReportDescriptor, hidReportDescriptorSize, false );
441
444
DynamicHID ().AppendDescriptor (node);
442
-
445
+ # endif
443
446
// Setup Joystick State
444
447
if (buttonCount > 0 ) {
445
448
_buttonValuesArraySize = _buttonCount / 8 ;
@@ -479,6 +482,12 @@ Joystick_::Joystick_(
479
482
480
483
void Joystick_::begin (bool initAutoSendState)
481
484
{
485
+ #ifdef USE_TINYUSB
486
+ _usb_hid.setPollInterval (2 );
487
+ _usb_hid.begin ();
488
+
489
+ while (!USBDevice.mounted ()) delay (1 );
490
+ #endif
482
491
_autoSendState = initAutoSendState;
483
492
sendState ();
484
493
}
@@ -676,7 +685,16 @@ void Joystick_::sendState()
676
685
index += buildAndSetSimulationValue (_includeSimulatorFlags & JOYSTICK_INCLUDE_BRAKE, _brake, _brakeMinimum, _brakeMaximum, &(data[index]));
677
686
index += buildAndSetSimulationValue (_includeSimulatorFlags & JOYSTICK_INCLUDE_STEERING, _steering, _steeringMinimum, _steeringMaximum, &(data[index]));
678
687
688
+ #ifdef USE_TINYUSB
689
+ if (_usb_hid.ready ()) {
690
+ _usb_hid.sendReport (_hidReportId, data, _hidReportSize);
691
+ }
692
+
693
+ if (USBDevice.suspended ())
694
+ USBDevice.remoteWakeup ();
695
+ #else
679
696
DynamicHID ().SendReport (_hidReportId, data, _hidReportSize);
697
+ #endif
680
698
}
681
699
682
700
#endif
0 commit comments