@@ -437,9 +437,12 @@ Joystick_::Joystick_(
437437 memcpy (customHidReportDescriptor, tempHidReportDescriptor, hidReportDescriptorSize);
438438
439439 // Register HID Report Description
440+ #ifdef USE_TINYUSB
441+ _usb_hid.setReportDescriptor (customHidReportDescriptor, hidReportDescriptorSize);
442+ #else
440443 DynamicHIDSubDescriptor *node = new DynamicHIDSubDescriptor (customHidReportDescriptor, hidReportDescriptorSize, false );
441444 DynamicHID ().AppendDescriptor (node);
442-
445+ # endif
443446 // Setup Joystick State
444447 if (buttonCount > 0 ) {
445448 _buttonValuesArraySize = _buttonCount / 8 ;
@@ -479,6 +482,12 @@ Joystick_::Joystick_(
479482
480483void Joystick_::begin (bool initAutoSendState)
481484{
485+ #ifdef USE_TINYUSB
486+ _usb_hid.setPollInterval (2 );
487+ _usb_hid.begin ();
488+
489+ while (!USBDevice.mounted ()) delay (1 );
490+ #endif
482491 _autoSendState = initAutoSendState;
483492 sendState ();
484493}
@@ -676,7 +685,16 @@ void Joystick_::sendState()
676685 index += buildAndSetSimulationValue (_includeSimulatorFlags & JOYSTICK_INCLUDE_BRAKE, _brake, _brakeMinimum, _brakeMaximum, &(data[index]));
677686 index += buildAndSetSimulationValue (_includeSimulatorFlags & JOYSTICK_INCLUDE_STEERING, _steering, _steeringMinimum, _steeringMaximum, &(data[index]));
678687
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
679696 DynamicHID ().SendReport (_hidReportId, data, _hidReportSize);
697+ #endif
680698}
681699
682700#endif
0 commit comments