Add missing features / fixed bug

This commit is contained in:
T-vK
2019-08-06 08:00:00 +00:00
parent cf18124bba
commit 642d2fb3f1
4 changed files with 22 additions and 18 deletions

View File

@@ -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();
}
}

View File

@@ -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.h>
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.

View File

@@ -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()<startTime+2000) {
bleMouse.move(0,0,0,1);
bleMouse.move(0,0,0,-1);
delay(100);
}
delay(500);
@@ -43,7 +43,7 @@ void loop() {
Serial.println("Scroll right");
startTime = millis();
while(millis()<startTime+2000) {
bleMouse.move(0,0,0,-1);
bleMouse.move(0,0,0,1);
delay(100);
}
delay(500);

View File

@@ -16,5 +16,5 @@ void loop() {
Serial.println("Scroll Down");
bleMouse.move(0,0,-1);
}
delay(1000);
delay(2000);
}