Krolyxon
Commit 3abfbfd

Branches

Tags

Refs →

orion-rflibBleMouseBleMouse.h

52 lines · 1.6 KB · Objective-C

1#ifndef ESP32_BLE_MOUSE_H
2#define ESP32_BLE_MOUSE_H
3#include "sdkconfig.h"
4#if defined(CONFIG_BT_ENABLED)
5
6#include "BLECharacteristic.h"
7#include "BLEHIDDevice.h"
8#include "BleConnectionStatus.h"
9
10#define MOUSE_LEFT 1
11#define MOUSE_RIGHT 2
12#define MOUSE_MIDDLE 4
13#define MOUSE_BACK 8
14#define MOUSE_FORWARD 16
15#define MOUSE_ALL \
16 (MOUSE_LEFT | MOUSE_RIGHT | \
17 MOUSE_MIDDLE) #For compatibility with the Mouse library
18
19class BleMouse {
20 private:
21 uint8_t _buttons;
22 BleConnectionStatus *connectionStatus;
23 BLEHIDDevice *hid;
24 BLECharacteristic *inputMouse;
25 void buttons(uint8_t b);
26 void rawAction(uint8_t msg[], char msgSize);
27 static void taskServer(void *pvParameter);
28
29 public:
30 BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse",
31 std::string deviceManufacturer = "Espressif",
32 uint8_t batteryLevel = 100);
33 void begin(void);
34 void end(void);
35 void click(uint8_t b = MOUSE_LEFT);
36 void move(signed char x, signed char y, signed char wheel = 0,
37 signed char hWheel = 0);
38 void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
39 void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
40 bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
41 bool isConnected(void);
42 void setBatteryLevel(uint8_t level);
43 uint8_t batteryLevel;
44 std::string deviceManufacturer;
45 std::string deviceName;
46
47 protected:
48 virtual void onStarted(BLEServer *pServer) {};
49};
50
51#endif // CONFIG_BT_ENABLED
52#endif // ESP32_BLE_MOUSE_H