This commit is contained in:
T-vK
2019-08-06 08:00:00 +00:00
parent 9ca44b3065
commit cf18124bba
5 changed files with 36 additions and 25 deletions

View File

@@ -108,10 +108,10 @@ void BleMouse::end(void)
void BleMouse::click(uint8_t b)
{
_buttons = b;
move(0,0,0,0);
_buttons = 0;
move(0,0,0,0);
_buttons = b;
move(0,0,0,0);
_buttons = 0;
move(0,0,0,0);
}
void BleMouse::move(signed char x, signed char y, signed char wheel, signed char hWheel)
@@ -119,10 +119,10 @@ void BleMouse::move(signed char x, signed char y, signed char wheel, signed char
if (this->isConnected())
{
uint8_t m[4];
m[0] = _buttons;
m[1] = x;
m[2] = wheel;
m[3] = hWheel;
m[0] = _buttons;
m[1] = x;
m[2] = wheel;
m[3] = hWheel;
this->inputMouse->setValue(m, 4);
this->inputMouse->notify();
}
@@ -130,28 +130,28 @@ void BleMouse::move(signed char x, signed char y, signed char wheel, signed char
void BleMouse::buttons(uint8_t b)
{
if (b != _buttons)
{
_buttons = b;
move(0,0,0,0);
}
if (b != _buttons)
{
_buttons = b;
move(0,0,0,0);
}
}
void BleMouse::press(uint8_t b)
{
buttons(_buttons | b);
buttons(_buttons | b);
}
void BleMouse::release(uint8_t b)
{
buttons(_buttons & ~b);
buttons(_buttons & ~b);
}
bool BleMouse::isPressed(uint8_t b)
{
if ((b & _buttons) > 0)
return true;
return false;
if ((b & _buttons) > 0)
return true;
return false;
}
bool BleMouse::isConnected(void) {

View File

@@ -17,6 +17,8 @@ This library allows you to make the ESP32 act as a Bluetooth Mouse and control w
- [x] Scroll up/down
- [x] Scroll left/right
### Example
``` C++

View File

@@ -13,6 +13,7 @@ void setup() {
void loop() {
if(bleMouse.isConnected()) {
unsigned long startTime;
Serial.println("Scroll up");

View File

@@ -10,13 +10,21 @@ BleMouse KEYWORD1
# Methods and Functions
#######################################
rawAction KEYWORD2
begin KEYWORD2
end KEYWORD2
click KEYWORD2
move KEYWORD2
press KEYWORD2
release KEYWORD2
isPressed KEYWORD2
isConnected KEYWORD2
scrollDown KEYWORD2
scrollUp KEYWORD2
init KEYWORD2
#######################################
# Constants
#######################################
MOUSE_LEFT LITERAL1
MOUSE_RIGHT LITERAL1
MOUSE_MIDDLE LITERAL1
MOUSE_BACK LITERAL1
MOUSE_FORWARD LITERAL1

View File

@@ -1,9 +1,9 @@
name=ESP32 BLE Mouse
version=1.0
version=0.1-alpha
author=T-vK
maintainer=T-vK
sentence=Bluetooth LE Mouse library for the ESP32.
paragraph=Bluetooth LE Mouse library for the ESP32.
category=Device Control
category=Communication
url=https://github.com/T-vK/ESP32-BLE-Mouse
architectures=*
architectures=esp32