Initial commit of Arduino libraries

This commit is contained in:
Sam
2025-05-23 10:47:41 +10:00
commit 5bfce5fc3e
2476 changed files with 1108481 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
#include "EspUsbHost.h"
class MyEspUsbHost : public EspUsbHost {
void onKeyboardKey(uint8_t ascii, uint8_t keycode, uint8_t modifier) {
if (' ' <= ascii && ascii <= '~') {
Serial.printf("%c", ascii);
} else if (ascii == '\r') {
Serial.println();
}
};
};
MyEspUsbHost usbHost;
void setup() {
Serial.begin(115200);
delay(500);
usbHost.begin();
usbHost.setHIDLocal(HID_LOCAL_Japan_Katakana);
}
void loop() {
usbHost.task();
}

View File

@@ -0,0 +1,88 @@
#include "EspUsbHost.h"
class MyEspUsbHost : public EspUsbHost {
void onMouseButtons(hid_mouse_report_t report, uint8_t last_buttons) {
Serial.printf("last_buttons=0x%02x(%c%c%c%c%c), buttons=0x%02x(%c%c%c%c%c), x=%d, y=%d, wheel=%d\n",
last_buttons,
(last_buttons & MOUSE_BUTTON_LEFT) ? 'L' : ' ',
(last_buttons & MOUSE_BUTTON_RIGHT) ? 'R' : ' ',
(last_buttons & MOUSE_BUTTON_MIDDLE) ? 'M' : ' ',
(last_buttons & MOUSE_BUTTON_BACKWARD) ? 'B' : ' ',
(last_buttons & MOUSE_BUTTON_FORWARD) ? 'F' : ' ',
report.buttons,
(report.buttons & MOUSE_BUTTON_LEFT) ? 'L' : ' ',
(report.buttons & MOUSE_BUTTON_RIGHT) ? 'R' : ' ',
(report.buttons & MOUSE_BUTTON_MIDDLE) ? 'M' : ' ',
(report.buttons & MOUSE_BUTTON_BACKWARD) ? 'B' : ' ',
(report.buttons & MOUSE_BUTTON_FORWARD) ? 'F' : ' ',
report.x,
report.y,
report.wheel);
// LEFT
if (!(last_buttons & MOUSE_BUTTON_LEFT) && (report.buttons & MOUSE_BUTTON_LEFT)) {
Serial.println("Mouse LEFT Click");
}
if ((last_buttons & MOUSE_BUTTON_LEFT) && !(report.buttons & MOUSE_BUTTON_LEFT)) {
Serial.println("Mouse LEFT Release");
}
// RIGHT
if (!(last_buttons & MOUSE_BUTTON_RIGHT) && (report.buttons & MOUSE_BUTTON_RIGHT)) {
Serial.println("Mouse RIGHT Click");
}
if ((last_buttons & MOUSE_BUTTON_RIGHT) && !(report.buttons & MOUSE_BUTTON_RIGHT)) {
Serial.println("Mouse RIGHT Release");
}
// MIDDLE
if (!(last_buttons & MOUSE_BUTTON_MIDDLE) && (report.buttons & MOUSE_BUTTON_MIDDLE)) {
Serial.println("Mouse MIDDLE Click");
}
if ((last_buttons & MOUSE_BUTTON_MIDDLE) && !(report.buttons & MOUSE_BUTTON_MIDDLE)) {
Serial.println("Mouse MIDDLE Release");
}
// BACKWARD
if (!(last_buttons & MOUSE_BUTTON_BACKWARD) && (report.buttons & MOUSE_BUTTON_BACKWARD)) {
Serial.println("Mouse BACKWARD Click");
}
if ((last_buttons & MOUSE_BUTTON_BACKWARD) && !(report.buttons & MOUSE_BUTTON_BACKWARD)) {
Serial.println("Mouse BACKWARD Release");
}
// FORWARD
if (!(last_buttons & MOUSE_BUTTON_FORWARD) && (report.buttons & MOUSE_BUTTON_FORWARD)) {
Serial.println("Mouse FORWARD Click");
}
if ((last_buttons & MOUSE_BUTTON_FORWARD) && !(report.buttons & MOUSE_BUTTON_FORWARD)) {
Serial.println("Mouse FORWARD Release");
}
};
void onMouseMove(hid_mouse_report_t report) {
Serial.printf("buttons=0x%02x(%c%c%c%c%c), x=%d, y=%d, wheel=%d\n",
report.buttons,
(report.buttons & MOUSE_BUTTON_LEFT) ? 'L' : ' ',
(report.buttons & MOUSE_BUTTON_RIGHT) ? 'R' : ' ',
(report.buttons & MOUSE_BUTTON_MIDDLE) ? 'M' : ' ',
(report.buttons & MOUSE_BUTTON_BACKWARD) ? 'B' : ' ',
(report.buttons & MOUSE_BUTTON_FORWARD) ? 'F' : ' ',
report.x,
report.y,
report.wheel);
};
};
MyEspUsbHost usbHost;
void setup() {
Serial.begin(115200);
delay(500);
usbHost.begin();
}
void loop() {
usbHost.task();
}