diff --git a/BleMouse.cpp b/BleMouse.cpp index b63e723..c50562c 100644 --- a/BleMouse.cpp +++ b/BleMouse.cpp @@ -118,12 +118,13 @@ void BleMouse::move(signed char x, signed char y, signed char wheel, signed char { if (this->isConnected()) { - uint8_t m[4]; + uint8_t m[5]; m[0] = _buttons; m[1] = x; - m[2] = wheel; - m[3] = hWheel; - this->inputMouse->setValue(m, 4); + m[2] = y; + m[3] = wheel; + m[4] = hWheel; + this->inputMouse->setValue(m, 5); this->inputMouse->notify(); } } diff --git a/README.md b/README.md index 3b0b3a1..f70b05d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,5 @@ # ESP32 BLE Mouse library -Bluetooth LE Mouse library for the ESP32 - -## Intro - 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. ## Features @@ -13,15 +9,22 @@ This library allows you to make the ESP32 act as a Bluetooth Mouse and control w - [x] Middle click - [x] Back/Forwards click - [x] Move mouse pointer left/right - - [ ] Move mouse pointer up/down (I'm working on it.) + - [x] Move mouse pointer up/down (I'm working on it.) - [x] Scroll up/down - [x] Scroll left/right +## Installation +- (Make sure you can use the ESP32 with the Arduino IDE. [Instructions can be found here.](https://github.com/espressif/arduino-esp32#installation-instructions)) +- [https://github.com/T-vK/ESP32-BLE-Mouse/releases](Download the latest release of this library from the release page.) +- 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 Mouse" and select any of the examples to get started. - -### Example +## Example ``` C++ +/** + * This example turns the ESP32 into a Bluetooth LE mouse that scrolls down every 2 seconds. + */ #include BleMouse bleMouse; @@ -37,11 +40,11 @@ void loop() { Serial.println("Scroll Down"); bleMouse.move(0,0,-1); } - delay(1000); + delay(2000); } ``` -### API docs +## 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/ @@ -56,6 +59,6 @@ This library supports two additional features that the Mouse library does not su - 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)` -### Credits +## Credits Credits to [chegewara](https://github.com/chegewara) as this library is based on [this piece of code](https://github.com/nkolban/esp32-snippets/issues/230#issuecomment-473135679) that he provided. \ No newline at end of file diff --git a/examples/ScrollAndMoveMouse/ScrollAndMoveMouse.ino b/examples/ScrollAndMoveMouse/ScrollAndMoveMouse.ino index fb97a30..492beb5 100644 --- a/examples/ScrollAndMoveMouse/ScrollAndMoveMouse.ino +++ b/examples/ScrollAndMoveMouse/ScrollAndMoveMouse.ino @@ -13,7 +13,7 @@ void setup() { void loop() { if(bleMouse.isConnected()) { - + unsigned long startTime; Serial.println("Scroll up"); @@ -35,7 +35,7 @@ void loop() { Serial.println("Scroll left"); startTime = millis(); while(millis()