| 1 | /** |
| 2 | * This example turns the ESP32 into a Bluetooth LE mouse that continuously moves the mouse. |
| 3 | */ |
| 4 | #include <BleMouse.h> |
| 5 | |
| 6 | BleMouse bleMouse; |
| 7 | |
| 8 | void setup() { |
| 9 | Serial.begin(115200); |
| 10 | Serial.println("Starting BLE work!"); |
| 11 | bleMouse.begin(); |
| 12 | } |
| 13 | |
| 14 | void loop() { |
| 15 | if(bleMouse.isConnected()) { |
| 16 | Serial.println("Left click"); |
| 17 | bleMouse.click(MOUSE_LEFT); |
| 18 | delay(500); |
| 19 | |
| 20 | Serial.println("Right click"); |
| 21 | bleMouse.click(MOUSE_RIGHT); |
| 22 | delay(500); |
| 23 | |
| 24 | Serial.println("Scroll wheel click"); |
| 25 | bleMouse.click(MOUSE_MIDDLE); |
| 26 | delay(500); |
| 27 | |
| 28 | Serial.println("Back button click"); |
| 29 | bleMouse.click(MOUSE_BACK); |
| 30 | delay(500); |
| 31 | |
| 32 | Serial.println("Forward button click"); |
| 33 | bleMouse.click(MOUSE_FORWARD); |
| 34 | delay(500); |
| 35 | |
| 36 | Serial.println("Click left+right mouse button at the same time"); |
| 37 | bleMouse.click(MOUSE_LEFT | MOUSE_RIGHT); |
| 38 | delay(500); |
| 39 | |
| 40 | Serial.println("Click left+right mouse button and scroll wheel at the same time"); |
| 41 | bleMouse.click(MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE); |
| 42 | delay(500); |
| 43 | |
| 44 | } |
| 45 | } |