Giter Site home page Giter Site logo

esp32-ble-mouse's Introduction

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:

Features

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

esp32-ble-mouse's People

Contributors

dvv avatar grafmar avatar ricalvrod avatar t-vk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.