Skip to content

ServAlex/ESP32-BLE-Combo

 
 

Repository files navigation

ESP32 BLE Combo Keyboard & Mouse library

This library allows you to make the ESP32 act as a Bluetooth keyboard and mouse with Arduino.

You might also be interested in:

Todo

  • Send key strokes
  • Send text
  • Press/release individual keys
  • Media keys are supported
  • Read Numlock/Capslock/Scrolllock state
  • Add gamepad support
  • Auto-instantiate Keyboard, Mouse objects (like the standard Arduino libraries)
  • Optimize so that only needed classes get created for BLE.
  • 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

  • (Make sure you can use the ESP32 with the Arduino IDE. Instructions can be found here.)
  • Download the latest release of this library from the release page. Arduino IDE:
  • In the Arduino IDE go to "Sketch" -> "Include Library" -> "Add .ZIP Library..." and select the file you just downloaded.
  • You can now go to "File" -> "Examples" -> "ESP32 BLE Combo" and select any of the examples to get started. VS Code:
  • In VS Code you can unzip downloaded .ZIP to your libraries directory (listed in your "includePath").

Example

#include <BleCombo.h>

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

void loop() {
  if(Keyboard.isConnected()) {
    Serial.println("Sending 'Hello world'");
    Keyboard.println("Hello World");

    Serial.println("Sending Enter key...");
    Keyboard.write(KEY_RETURN);

    Serial.println("Sending Play/Pause media key...");
    Keyboard.write(KEY_MEDIA_PLAY_PAUSE);

    Serial.println("Sending Ctrl+Alt+Delete...");
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press(KEY_LEFT_ALT);
    Keyboard.press(KEY_DELETE);
    delay(100);
    Keyboard.releaseAll();

    Serial.println("Move mouse pointer up");
    Mouse.move(0,-10);
    
    Serial.println("Scroll Down");
    Mouse.move(0,0,-1);

    Serial.println("Left click");
    Mouse.click(MOUSE_LEFT);
  }
  
  Serial.println("Waiting 2 seconds...");
  delay(2000);
}

Credits

This is a fork of @blackketter's fork of @T-kV's excellent ESP32-BLE-Mouse and ESP32-BLE-Keyboard libraries with fixes backported (up to December 2020).

About

Bluetooth LE Keyboard/Mouse Combo library for the ESP32 (Arduino IDE compatible)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 99.3%
  • C 0.7%