Skip to content

Commit 0c5a29b

Browse files
committed
all hid examples work with esp32s2
1 parent f5b5f05 commit 0c5a29b

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

examples/Composite/mouse_external_flash/mouse_external_flash.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "Adafruit_TinyUSB.h"
2121

2222
//--------------------------------------------------------------------+
23-
// MSC External Flash
23+
// MSC External Flash Config
2424
//--------------------------------------------------------------------+
2525

2626
// Uncomment to run example with FRAM
@@ -56,7 +56,7 @@ Adafruit_SPIFlash flash(&flashTransport);
5656
Adafruit_USBD_MSC usb_msc;
5757

5858
//--------------------------------------------------------------------+
59-
// HID
59+
// HID Config
6060
//--------------------------------------------------------------------+
6161

6262
// HID report descriptor using TinyUSB's template

examples/HID/hid_composite_joy_featherwing/hid_composite_joy_featherwing.ino

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ uint8_t const desc_hid_report[] =
4646
TUD_HID_REPORT_DESC_MOUSE ( HID_REPORT_ID(RID_MOUSE) )
4747
};
4848

49-
// USB HID object
50-
Adafruit_USBD_HID usb_hid;
49+
// USB HID object. For ESP32 these values cannot be changed after this declaration
50+
// desc report, desc len, protocol, interval, use out endpoint
51+
Adafruit_USBD_HID usb_hid(desc_hid_report, sizeof(desc_hid_report), HID_ITF_PROTOCOL_NONE, 2, false);
5152

5253
int last_x, last_y;
5354

5455
// the setup function runs once when you press reset or power the board
5556
void setup()
5657
{
57-
usb_hid.setPollInterval(2);
58-
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
58+
// Notes: following commented-out functions has no affect on ESP32
59+
// usb_hid.setPollInterval(2);
60+
// usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
5961

6062
usb_hid.begin();
6163

examples/HID/hid_gamepad/hid_gamepad.ino

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ uint8_t const desc_hid_report[] =
2727
TUD_HID_REPORT_DESC_GAMEPAD()
2828
};
2929

30-
// USB HID object
31-
Adafruit_USBD_HID usb_hid;
30+
// USB HID object. For ESP32 these values cannot be changed after this declaration
31+
// desc report, desc len, protocol, interval, use out endpoint
32+
Adafruit_USBD_HID usb_hid(desc_hid_report, sizeof(desc_hid_report), HID_ITF_PROTOCOL_NONE, 2, false);
3233

33-
hid_gamepad_report_t gp; // defined in hid.h from Adafruit_TinyUSB_ArduinoCore
34-
// For Gamepad Button Bit Mask see hid_gamepad_button_bm_t typedef defined in hid.h from Adafruit_TinyUSB_ArduinoCore
35-
// For Gamepad Hat Bit Mask see hid_gamepad_hat_bm_t typedef defined in hid.h from Adafruit_TinyUSB_ArduinoCore
34+
// Report payload defined in src/class/hid/hid.h
35+
// - For Gamepad Button Bit Mask see hid_gamepad_button_bm_t
36+
// - For Gamepad Hat Bit Mask see hid_gamepad_hat_t
37+
hid_gamepad_report_t gp;
3638

3739
void setup()
3840
{
@@ -43,8 +45,9 @@ void setup()
4345

4446
Serial.begin(115200);
4547

46-
usb_hid.setPollInterval(2);
47-
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
48+
// Notes: following commented-out functions has no affect on ESP32
49+
// usb_hid.setPollInterval(2);
50+
// usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
4851

4952
usb_hid.begin();
5053

@@ -66,7 +69,6 @@ void loop()
6669

6770
if ( !usb_hid.ready() ) return;
6871

69-
7072
// Reset buttons
7173
Serial.println("No pressing buttons");
7274
gp.x = 0;

0 commit comments

Comments
 (0)