8000 For consistency, BTHID Joypad->Joystick (#2218) · TGralla/arduino-pico@f272995 · GitHub
[go: up one dir, main page]

Skip to content

Commit f272995

Browse files
For consistency, BTHID Joypad->Joystick (earlephilhower#2218)
Matches existing library names and nomenclature
1 parent db13d3c commit f272995

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

docs/hidmaster.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ HID key and the up/down state to the stream and read back the ASCII for use in a
119119
120120
Joystick Callbacks
121121
~~~~~~~~~~~~~~~~~~
122-
A single ``BluetoothHIDMaster::onJoypad`` callback gets activated every time a report from a joystick is processed.
122+
A single ``BluetoothHIDMaster::onJoystick`` callback gets activated every time a report from a joystick is processed.
123123
It receives (potentially, if supported by the device) 4 analog axes, one 8-way digital hat switch position, and up
124124
to 32 button states at a time.
125125

126126
.. code :: cpp
127127
128-
void joypadCB(void *cbdata, int x, int y, int z, int rz, uint8_t hat, uint32_t buttons) {
128+
void joystickCB(void *cbdata, int x, int y, int z, int rz, uint8_t hat, uint32_t buttons) {
129129
// HAT 0 = UP and continues clockwise. If no hat direction it is set to 0x0f.
130130
// Use "buttons & (1 << buttonNumber)" to look at the individual button states
131131
// ...
@@ -147,7 +147,7 @@ BluetoothHIDMaster::onXXX Callback Installers
147147
void BluetoothHIDMaster::onKeyUp(void (*)(void *, int), void *cbData = nullptr);
148148
void BluetoothHIDMaster::onConsumerKeyDown(void (*)(void *, int), void *cbData = nullptr);
149149
void BluetoothHIDMaster::onConsumerKeyUp(void (*)(void *, int), void *cbData = nullptr);
150-
void BluetoothHIDMaster::onJoypad(void (*)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData = nullptr);
150+
void BluetoothHIDMaster::onJoystick(void (*)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData = nullptr);
151151
152152
BluetoothHIDMaster Class
153153
------------------------
@@ -187,7 +187,7 @@ bool BluetoothHIDMaster::connect(const uint8_t *addr)
187187
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
188188
Start the connection process to the Bluetooth Classic device with the given MAC. Note that this returns immediately, but it may take several seconds until ``connected()`` reports that the connection has been established.
189189
190-
bool BluetoothHIDMaster::connectKeyboard(), connectMouse(), connectJoypad(), connectAny()
190+
bool BluetoothHIDMaster::connectKeyboard(), connectMouse(), connectJoystick(), connectAny()
191191
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
192192
Connect to the first found specified Bluetooth Classic device type (or any HID device) in pairing mode. No need to call ``scan()`` or have an address.
193193

libraries/BluetoothHIDMaster/examples/KeyboardPiano/KeyboardPiano.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void ckb(void *cbdata, int key) {
159159

160160

161161
// Joystick can get reports of 4 analog axes, 1 d-pad bitfield, and up to 32 buttons
162-
// Axes and hats that aren't reported by the pad are read as 0
162+
// Axes and hats that aren't reported by the joystick are read as 0
163163
void joy(void *cbdata, int x, int y, int z, int rz, uint8_t hat, uint32_t buttons) {
164164
(void) cbdata;
165165
const char *hats[16] = { "U", "UR", "R", "DR", "D", "DL", "L", "UL", "", "", "", "", "", "", "", "." };
@@ -202,7 +202,7 @@ void setup() {
202202
hid.onConsumerKeyDown(ckb, (void *)true);
203203
hid.onConsumerKeyUp(ckb, (void *)false);
204204

205-
hid.onJoypad(joy);
205+
hid.onJoystick(joy);
206206

207207
hid.begin();
208208

libraries/BluetoothHIDMaster/examples/KeyboardPianoBLE/KeyboardPianoBLE.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void ckb(void *cbdata, int key) {
158158
}
159159

160160
// Joystick can get reports of 4 analog axes, 1 d-pad bitfield, and up to 32 buttons
161-
// Axes and hats that aren't reported by the pad are read as 0
161+
// Axes and hats that aren't reported by the joystick are read as 0
162162
void joy(void *cbdata, int x, int y, int z, int rz, uint8_t hat, uint32_t buttons) {
163163
(void) cbdata;
164164
const char *hats[16] = { "U", "UR", "R", "DR", "D", "DL", "L", "UL", "", "", "", "", "", "", "", "." };
@@ -202,7 +202,7 @@ void setup() {
202202
hid.onConsumerKeyDown(ckb, (void *)true);
203203
hid.onConsumerKeyUp(ckb, (void *)false);
204204

205-
hid.onJoypad(joy);
205+
hid.onJoystick(joy);
206206

207207
hid.begin(true);
208208

libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ void BluetoothHIDMaster::onConsumerKeyUp(void (*cb)(void *, int), void *cbData)
161161
_consumerKeyUpData = cbData;
162162
}
163163

164-
void BluetoothHIDMaster::onJoypad(void (*cb)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData) {
165-
_joypadCB = cb;
166-
_joypadData = cbData;
164+
void BluetoothHIDMaster::onJoystick(void (*cb)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData) {
165+
_joystickCB = cb;
166+
_joystickData = cbData;
167167
}
168168

169169
std::list<BTDeviceInfo> BluetoothHIDMaster::scan(uint32_t mask, int scanTimeSec, bool async) {
@@ -257,7 +257,7 @@ bool BluetoothHIDMaster::connectMouse() {
257257
return connectCOD(0x2580);
258258
}
259259

260-
bool BluetoothHIDMaster::connectJoypad() {
260+
bool BluetoothHIDMaster::connectJoystick() {
261261
return connectCOD(0x2508);
262262
}
263263

@@ -427,8 +427,8 @@ void BluetoothHIDMaster::hid_host_handle_interrupt_report(btstack_hid_parser_t *
427427
if (updMouse && _mouseMoveCB) {
428428
_mouseMoveCB(_mouseMoveData, dx, dy, dwheel);
429429
}
430-
if (updJoy && _joypadCB) {
431-
_joypadCB(_joypadData, dx, dy, dz, rz, hat, newMB);
430+
if (updJoy && _joystickCB) {
431+
_joystickCB(_joystickData, dx, dy, dz, rz, hat, newMB);
432432
}
433433
}
434434

libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Bluetooth HID Master class, can connect to keyboards, mice, and joypads
2+
Bluetooth HID Master class, can connect to keyboards, mice, and joysticks
33
Works with Bluetooth Classic and BLE devices
44
55
Copyright (c) 2024 Earle F. Philhower, III <earlephilhower@yahoo.com>
@@ -78,7 +78,7 @@ class BluetoothHIDMaster {
7878

7979
static const uint32_t keyboard_cod = 0x2540;
8080
static const uint32_t mouse_cod = 0x2540;
81-
static const uint32_t joypad_cod = 0x2508;
81+
static const uint32_t joystick_cod = 0x2508;
8282
static const uint32_t any_cod = 0;
8383
std::list<BTDeviceInfo> scan(uint32_t mask, int scanTimeSec = 5, bool async = false);
8484
bool scanAsyncDone();
@@ -87,7 +87,7 @@ class BluetoothHIDMaster {
8787
bool connect(const uint8_t *addr);
8888
bool connectKeyboard();
8989
bool connectMouse();
90-
bool connectJoypad();
90+
bool connectJoystick();
9191
bool connectAny();
9292

9393
bool connectBLE(const uint8_t *addr, int addrType);
@@ -102,7 +102,7 @@ class BluetoothHIDMaster {
102102
void onKeyUp(void (*)(void *, int), void *cbData = nullptr);
103103
void onConsumerKeyDown(void (*)(void *, int), void *cbData = nullptr);
104104
void onConsumerKeyUp(void (*)(void *, int), void *cbData = nullptr);
105-
void onJoypad(void (*)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData = nullptr);
105+
void onJoystick(void (*)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData = nullptr);
106106

107107
private:
108108
bool _ble = false;
@@ -135,8 +135,8 @@ class BluetoothHIDMaster {
135135
void (*_consumerKeyUpCB)(void *, int) = nullptr;
136136
void *_consumerKeyUpData;
137137

138-
void (*_joypadCB)(void *, int, int, int, int, uint8_t, uint32_t) = nullptr;
139-
void *_joypadData;
138+
void (*_joystickCB)(void *, int, int, int, int, uint8_t, uint32_t) = nullptr;
139+
void *_joystickData;
140140

141141

142142
btstack_packet_callback_registration_t _sm_event_callback_registration;

0 commit comments

Comments
 (0)
0