MCPcopy Create free account
hub / github.com/T-vK/ESP32-BLE-Mouse

github.com/T-vK/ESP32-BLE-Mouse @0.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.3.1 ↗ · + Follow
17 symbols 19 edges 4 files 0 documented · 0% updated 2y ago0.3.1 · 2020-10-20★ 1,00654 open issues

Browse by type

Functions 15 Types & classes 2
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ESP32 BLE Mouse library

This library allows you to make the ESP32 act as a Bluetooth Mouse and control what it does. E.g. move the mouse, scroll, make a click etc.

You might also be interested in: - ESP32-BLE-Keyboard - ESP32-BLE-Gamepad

Features

  • [x] Left click
  • [x] Right click
  • [x] Middle click
  • [x] Back/Forwards click
  • [x] Move mouse pointer left/right
  • [x] Move mouse pointer up/down
  • [x] Scroll up/down
  • [x] Scroll left/right
  • [x] Report optional battery level to host (basically works, but it doesn't show up in Android's status bar)
  • [x] Customize Bluetooth device name/manufacturer
  • [x] Compatible with Android
  • [x] Compatible with Windows
  • [x] Compatible with Linux
  • [x] Compatible with MacOS X (not stable, some people have issues, doesn't work with old devices)
  • [x] Compatible with iOS (not stable, some people have issues, doesn't work with old devices)

Installation

Example

/**
 * This example turns the ESP32 into a Bluetooth LE mouse that scrolls down every 2 seconds.
 */
#include <BleMouse.h>

BleMouse bleMouse;

void setup() {
  Serial.begin(115200);
  Serial.println("Starting BLE work!");
  bleMouse.begin();
}

void loop() {
  if(bleMouse.isConnected()) {
    Serial.println("Scroll Down");
    bleMouse.move(0,0,-1);
  }
  delay(2000);
}

API docs

The BleMouse interface is almost identical to the Mouse Interface, so you can use documentation right here: https://www.arduino.cc/reference/en/language/functions/usb/mouse/

Just remember that you have to use bleMouse instead of just Mouse and you need these two lines at the top of your script:

#include <BleMouse.h>
BleMouse bleMouse;

This library supports a few additional features that the Mouse library does not support at the time of writing:

  • Scrolling left/right E.g.: bleMouse.move(0,0,0,1) (Scroll left) and bleMouse.move(0,0,0,-1) (Scroll right)
  • Using the back and forward buttons E.g.: bleMouse.click(MOUSE_BACK) and bleMouse.click(MOUSE_FORWARD)

There is also Bluetooth specific information that you can use (optional):

Instead of BleMouse bleMouse; you can do BleMouse bleMouse("Bluetooth Device Name", "Bluetooth Device Manufacturer", 100);. The third parameter is the initial battery level of your device. To adjust the battery level later on you can simply call e.g. bleMouse.setBatteryLevel(50) (set battery level to 50%). By default the battery level will be set to 100%, the device name will be ESP32 Bluetooth Mouse and the manufacturer will be Espressif.

Credits

Credits to chegewara as this library is based on this piece of code that he provided.

Core symbols most depended-on inside this repo

Shape

Method 15
Class 2

Languages

C++100%

Modules by API surface

BleMouse.cpp12 symbols
BleConnectionStatus.cpp3 symbols
BleMouse.h1 symbols
BleConnectionStatus.h1 symbols

For agents

$ claude mcp add ESP32-BLE-Mouse \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page