Skip to content

Commit 9760efb

Browse files
Clean up the BT HID libraries a bit (#1236)
1 parent d92c102 commit 9760efb

File tree

6 files changed

+27
-23
lines changed

6 files changed

+27
-23
lines changed

libraries/JoystickBT/src/JoystickBT.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ int JoystickBT_::map8or10bit(int const value) {
7979
#define REPORT_ID 0x01
8080
static const uint8_t desc_joystick[] = {TUD_HID_REPORT_DESC_GAMEPAD(HID_REPORT_ID(REPORT_ID))};
8181
void JoystickBT_::begin(void) {
82-
_PicoBluetoothHID.startHID("PicoW Joystick 00:00:00:00:00:00", "PicoW HID Joystick", 0x2508, 33, desc_joystick, sizeof(desc_joystick));
82+
PicoBluetoothHID.startHID("PicoW Joystick 00:00:00:00:00:00", "PicoW HID Joystick", 0x2508, 33, desc_joystick, sizeof(desc_joystick));
8383
}
8484

8585
void JoystickBT_::end(void) {
86-
_PicoBluetoothHID.end();
86+
PicoBluetoothHID.end();
8787
}
8888

8989
void JoystickBT_::button(uint8_t button, bool val) {
@@ -178,7 +178,7 @@ void JoystickBT_::hat(int angle) {
178178

179179
//immediately send an HID report
180180
void JoystickBT_::send_now(void) {
181-
_PicoBluetoothHID.send(REPORT_ID, &data, sizeof(data));
181+
PicoBluetoothHID.send(REPORT_ID, &data, sizeof(data));
182182
}
183183

184184
JoystickBT_ JoystickBT;

libraries/KeyboardBT/src/KeyboardBT.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ KeyboardBT_::KeyboardBT_(void) {
3838
static const uint8_t desc_keyboard[] = {TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(REPORT_ID))};
3939
void KeyboardBT_::begin(const uint8_t *layout) {
4040
_asciimap = layout;
41-
_PicoBluetoothHID.startHID("PicoW Keyboard 00:00:00:00:00:00", "PicoW HID Keyboard", 0x2540, 33, desc_keyboard, sizeof(desc_keyboard));
41+
PicoBluetoothHID.startHID("PicoW Keyboard 00:00:00:00:00:00", "PicoW HID Keyboard", 0x2540, 33, desc_keyboard, sizeof(desc_keyboard));
4242
}
4343

4444
void KeyboardBT_::end(void) {
45-
_PicoBluetoothHID.end();
45+
PicoBluetoothHID.end();
4646
}
4747

4848
void KeyboardBT_::sendReport(KeyReport* keys) {
4949
hid_keyboard_report_t data;
5050
data.modifier = keys->modifiers;
5151
data.reserved = 0;
5252
memcpy(data.keycode, keys->keys, sizeof(data.keycode));
53-
_PicoBluetoothHID.send(REPORT_ID, &data, sizeof(data));
53+
PicoBluetoothHID.send(REPORT_ID, &data, sizeof(data));
5454
}
5555

5656
// press() adds the specified key (printing, non-printing, or modifier)

libraries/MouseBT/src/MouseBT.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ MouseBT_::MouseBT_(void) : _buttons(0) {
4747
#define REPORT_ID 0x01
4848
const uint8_t desc_mouse[] = {TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(REPORT_ID))};
4949
void MouseBT_::begin(void) {
50-
_PicoBluetoothHID.startHID("PicoW Mouse 00:00:00:00:00:00", "PicoW HID Mouse", 0x2580, 33, desc_mouse, sizeof(desc_mouse));
50+
PicoBluetoothHID.startHID("PicoW Mouse 00:00:00:00:00:00", "PicoW HID Mouse", 0x2580, 33, desc_mouse, sizeof(desc_mouse));
5151
}
5252

5353
void MouseBT_::end(void) {
54-
_PicoBluetoothHID.end();
54+
PicoBluetoothHID.end();
5555
}
5656

5757
void MouseBT_::click(uint8_t b) {
@@ -70,7 +70,7 @@ void MouseBT_::move(int x, int y, signed char wheel) {
7070
data.y = limit_xy(y);
7171
data.wheel = wheel;
7272
data.pan = 0;
73-
_PicoBluetoothHID.send(REPORT_ID, &data, sizeof(data));
73+
PicoBluetoothHID.send(REPORT_ID, &data, sizeof(data));
7474
}
7575

7676
void MouseBT_::buttons(uint8_t b) {

libraries/PicoBluetoothHID/keywords.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ PicoBluetoothHID KEYWORD1
1212
# Methods and Functions (KEYWORD2)
1313
#######################################
1414

15-
begin KEYWORD2
16-
write KEYWORD2
17-
press KEYWORD2
18-
release KEYWORD2
19-
releaseAll KEYWORD2
15+
setOpenedCB KEYWORD2
16+
setClosedCB KEYWORD2
17+
seCanSendNowCB KEYWORD2
18+
startHID KEYWORD2
19+
connected KEYWORD2
20+
send KEYWORD2
21+
lockBluetooth KEYWORD2
22+
unlockBluetooth KEYWORD2
23+
getCID KEYWORD2
2024

2125
#######################################
2226
# Constants (LITERAL1)

libraries/PicoBluetoothHID/src/PicoBluetoothHID.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020

2121
#include "PicoBluetoothHID.h"
2222

23-
PicoBluetoothHID _PicoBluetoothHID;
23+
PicoBluetoothHID_ PicoBluetoothHID;

libraries/PicoBluetoothHID/src/PicoBluetoothHID.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@
3737
#undef HID_REPORT_TYPE_OUTPUT
3838
#undef HID_REPORT_TYPE_INPUT
3939

40-
class PicoBluetoothHID;
41-
extern PicoBluetoothHID _PicoBluetoothHID;
40+
class PicoBluetoothHID_;
41+
extern PicoBluetoothHID_ PicoBluetoothHID;
4242

43-
class PicoBluetoothHID {
43+
class PicoBluetoothHID_ {
4444
public:
45-
PicoBluetoothHID() {
45+
PicoBluetoothHID_() {
4646
}
4747

48-
~PicoBluetoothHID() {
48+
~PicoBluetoothHID_() {
4949
}
5050

5151
// Optional callback, not used presently
52-
// Usage: _PicoBluetoothHID.setCanSendNowCB(std::bind(&kbd::onCanSendNow, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
52+
// Usage: PicoBluetoothHID.setCanSendNowCB(std::bind(&kbd::onCanSendNow, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4));
5353
typedef std::function<void(uint8_t type, uint16_t channel, uint8_t *packet, uint16_t size)> BTCallback;
5454

5555
void setOpenedCB(BTCallback cb) {
@@ -135,7 +135,7 @@ class PicoBluetoothHID {
135135
}
136136

137137
static void PacketHandlerWrapper(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t packet_size) {
138-
_PicoBluetoothHID.packetHandler(packet_type, channel, packet, packet_size);
138+
PicoBluetoothHID.packetHandler(packet_type, channel, packet, packet_size);
139139
}
140140

141141
void packetHandler(uint8_t type, uint16_t channel, uint8_t *packet, uint16_t size) {
@@ -215,7 +215,7 @@ class PicoBluetoothHID {
215215
_sendReport = rpt;
216216
_sendReportLen = len;
217217
lockBluetooth();
218-
hid_device_request_can_send_now_event(_PicoBluetoothHID.getCID());
218+
hid_device_request_can_send_now_event(getCID());
219219
unlockBluetooth();
220220
while (connected() && _needToSend) {
221221
/* noop busy wait */

0 commit comments

Comments
 (0)