Skip to content

Commit 642d2fb

Browse files
committed
Add missing features / fixed bug
1 parent cf18124 commit 642d2fb

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

BleMouse.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ void BleMouse::move(signed char x, signed char y, signed char wheel, signed char
118118
{
119119
if (this->isConnected())
120120
{
121-
uint8_t m[4];
121+
uint8_t m[5];
122122
m[0] = _buttons;
123123
m[1] = x;
124-
m[2] = wheel;
125-
m[3] = hWheel;
126-
this->inputMouse->setValue(m, 4);
124+
m[2] = y;
125+
m[3] = wheel;
126+
m[4] = hWheel;
127+
this->inputMouse->setValue(m, 5);
127128
this->inputMouse->notify();
128129
}
129130
}

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# ESP32 BLE Mouse library
22

3-
Bluetooth LE Mouse library for the ESP32
4-
5-
## Intro
6-
73
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.
84

95
## Features
@@ -13,15 +9,22 @@ This library allows you to make the ESP32 act as a Bluetooth Mouse and control w
139
- [x] Middle click
1410
- [x] Back/Forwards click
1511
- [x] Move mouse pointer left/right
16-
- [ ] Move mouse pointer up/down (I'm working on it.)
12+
- [x] Move mouse pointer up/down (I'm working on it.)
1713
- [x] Scroll up/down
1814
- [x] Scroll left/right
1915

16+
## Installation
17+
- (Make sure you can use the ESP32 with the Arduino IDE. [Instructions can be found here.](https://github.com/espressif/arduino-esp32#installation-instructions))
18+
- [https://github.com/T-vK/ESP32-BLE-Mouse/releases](Download the latest release of this library from the release page.)
19+
- In the Arduino IDE go to "Sketch" -> "Include Library" -> "Add .ZIP Library..." and select the file you just downloaded.
20+
- You can now go to "File" -> "Examples" -> "ESP32 BLE Mouse" and select any of the examples to get started.
2021

21-
22-
### Example
22+
## Example
2323

2424
``` C++
25+
/**
26+
* This example turns the ESP32 into a Bluetooth LE mouse that scrolls down every 2 seconds.
27+
*/
2528
#include <BleMouse.h>
2629

2730
BleMouse bleMouse;
@@ -37,11 +40,11 @@ void loop() {
3740
Serial.println("Scroll Down");
3841
bleMouse.move(0,0,-1);
3942
}
40-
delay(1000);
43+
delay(2000);
4144
}
4245
```
4346

44-
### API docs
47+
## API docs
4548
The BleMouse interface is almost identical to the Mouse Interface, so you can use documentation right here:
4649
https://www.arduino.cc/reference/en/language/functions/usb/mouse/
4750

@@ -56,6 +59,6 @@ This library supports two additional features that the Mouse library does not su
5659
- Scrolling left/right E.g.: `bleMouse.move(0,0,0,1)` (Scroll left) and `bleMouse.move(0,0,0,-1)` (Scroll right)
5760
- Using the back and forward buttons E.g.: `bleMouse.click(MOUSE_BACK)` and `bleMouse.click(MOUSE_FORWARD)`
5861

59-
### Credits
62+
## Credits
6063

6164
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.

examples/ScrollAndMoveMouse/ScrollAndMoveMouse.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void setup() {
1313

1414
void loop() {
1515
if(bleMouse.isConnected()) {
16-
16+
1717
unsigned long startTime;
1818

1919
Serial.println("Scroll up");
@@ -35,15 +35,15 @@ void loop() {
3535
Serial.println("Scroll left");
3636
startTime = millis();
3737
while(millis()<startTime+2000) {
38-
bleMouse.move(0,0,0,1);
38+
bleMouse.move(0,0,0,-1);
3939
delay(100);
4040
}
4141
delay(500);
4242

4343
Serial.println("Scroll right");
4444
startTime = millis();
4545
while(millis()<startTime+2000) {
46-
bleMouse.move(0,0,0,-1);
46+
bleMouse.move(0,0,0,1);
4747
delay(100);
4848
}
4949
delay(500);

examples/ScrollDown/ScrollDown.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ void loop() {
1616
Serial.println("Scroll Down");
1717
bleMouse.move(0,0,-1);
1818
}
19-
delay(1000);
19+
delay(2000);
2020
}

0 commit comments

Comments
 (0)