diff options
| author | krolyxon <me@krolyxon.com> | 2026-05-11 14:01:44 +0530 |
|---|---|---|
| committer | krolyxon <me@krolyxon.com> | 2026-05-11 14:01:44 +0530 |
| commit | f34b1e2fbd94bcc8d0ee2e2e2e43e214d0b329a1 (patch) | |
| tree | 235d29da4668906d1e11d651980cea8b0c69dec7 /src/ble_mouse.cpp | |
| parent | 360d2d2ad3bd584014683f3579fc2e2348c16852 (diff) | |
Migrate to PlatformIO
Now since i have been able to make PSRAM working with platformio, i
don't have to use this shitty Arduino-IDE anymore which does not even
allow me to use subfolders like a normal programmer would do
Diffstat (limited to 'src/ble_mouse.cpp')
| -rw-r--r-- | src/ble_mouse.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/ble_mouse.cpp b/src/ble_mouse.cpp new file mode 100644 index 0000000..0035eb5 --- /dev/null +++ b/src/ble_mouse.cpp @@ -0,0 +1,74 @@ +#include <Arduino.h> +#include <BleMouse.h> +#include "badusb.h" +#include "config.h" + +#include "buttons.h" +#include "ui/display.h" + +// ===== BLE MOUSE ===== +// BleMouse bleMouse("Orion-RF", "Orion-RF", 100); +extern BleMouse bleMouse; + +// ===== MAIN ===== +void ble_mouse_run() +{ + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x10_tr); + u8g2.drawStr(10, 25, "BLE Mouse"); + u8g2.drawStr(10, 45, "Connecting..."); + u8g2.sendBuffer(); + + delay(800); + + while (1) + { + // 🔥 EXIT FIRST (clean) + if (btnBack()) break; + + bool connected = bleMouse.isConnected(); + + int dx = 0; + int dy = 0; + + if (connected) + { + if (!digitalRead(BTN_UP)) dy = -6; + if (!digitalRead(BTN_DOWN)) dy = 6; + if (!digitalRead(BTN_LEFT)) dx = -6; + if (!digitalRead(BTN_RIGHT)) dx = 6; + + if (dx || dy) + bleMouse.move(dx, dy); + + // ✅ single click (not spam) + static bool lastSelect = false; + bool currentSelect = !digitalRead(BTN_SELECT); + + if (currentSelect && !lastSelect) + bleMouse.click(MOUSE_LEFT); + + lastSelect = currentSelect; + } + + // ===== UI ===== + u8g2.clearBuffer(); + u8g2.setFont(u8g2_font_6x10_tr); + + u8g2.drawStr(10, 20, "BLE Mouse"); + + if (connected) + u8g2.drawStr(10, 35, "Connected"); + else + u8g2.drawStr(10, 35, "Waiting"); + + u8g2.drawStr(10, 55, "BACK = Exit"); + + u8g2.sendBuffer(); + + delay(10); // important for BLE stability + } +} + + + |
