Last active
May 6, 2022 14:21
-
-
Save hollyhockberry/a627dddc95a8361c9d8a16415693d14b to your computer and use it in GitHub Desktop.
M5Unified: Click on the edge of the iPad screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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