Implement USB HID Device Support for ESP32-S2 (#5538)

* Add support and example for USB HID Devices
* Add support and example for USB Vendor
This commit is contained in:
Me No Dev
2021-08-23 17:27:34 +03:00
committed by GitHub
parent b1d072df9f
commit c45cff5f83
66 changed files with 3259 additions and 47 deletions

View File

@ -0,0 +1,21 @@
#include "USB.h"
#include "USBHIDSystemControl.h"
USBHIDSystemControl SystemControl;
const int buttonPin = 0;
int previousButtonState = HIGH;
void setup() {
pinMode(buttonPin, INPUT_PULLUP);
SystemControl.begin();
USB.begin();
}
void loop() {
int buttonState = digitalRead(buttonPin);
if ((buttonState != previousButtonState) && (buttonState == LOW)) {
SystemControl.press(SYSTEM_CONTROL_POWER_OFF);
SystemControl.release();
}
previousButtonState = buttonState;
}