Skip to content

Instantly share code, notes, and snippets.

@hollyhockberry
Last active May 6, 2022 14:21
Show Gist options
  • Save hollyhockberry/a627dddc95a8361c9d8a16415693d14b to your computer and use it in GitHub Desktop.
Save hollyhockberry/a627dddc95a8361c9d8a16415693d14b to your computer and use it in GitHub Desktop.
M5Unified: Click on the edge of the iPad screen
#include <M5Unified.h>
#include <BleMouse.h> // https://github.com/T-vK/ESP32-BLE-Mouse
BleMouse mouse;
void move(bool left) {
const uint8_t dx = 100 * (left ? -1 : 1);
for (auto i = 0; i < 10; ++i) {
mouse.move(dx, 0);
::delay(1);
}
mouse.click(MOUSE_LEFT);
}
void setup() {
M5.begin();
mouse.begin();
}
void loop() {
if (!mouse.isConnected()) return;
M5.update();
if (M5.BtnA.wasClicked()) {
::move(true);
} else if (M5.BtnA.wasHold()) {
::move(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment