Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-pico
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-pico
Commits
f2729955
Unverified
Commit
f2729955
authored
Jun 10, 2024
by
Earle F. Philhower, III
Committed by
GitHub
Jun 10, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For consistency, BTHID Joypad->Joystick (#2218)
Matches existing library names and nomenclature
parent
db13d3c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
20 deletions
+20
-20
docs/hidmaster.rst
docs/hidmaster.rst
+4
-4
libraries/BluetoothHIDMaster/examples/KeyboardPiano/KeyboardPiano.ino
...uetoothHIDMaster/examples/KeyboardPiano/KeyboardPiano.ino
+2
-2
libraries/BluetoothHIDMaster/examples/KeyboardPianoBLE/KeyboardPianoBLE.ino
...hHIDMaster/examples/KeyboardPianoBLE/KeyboardPianoBLE.ino
+2
-2
libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp
libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp
+6
-6
libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.h
libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.h
+6
-6
No files found.
docs/hidmaster.rst
View file @
f2729955
...
...
@@ -119,13 +119,13 @@ HID key and the up/down state to the stream and read back the ASCII for use in a
Joystick Callbacks
~~~~~~~~~~~~~~~~~~
A single ``BluetoothHIDMaster::onJoy
pad
`` callback gets activated every time a report from a joystick is processed.
A single ``BluetoothHIDMaster::onJoy
stick
`` callback gets activated every time a report from a joystick is processed.
It receives (potentially, if supported by the device) 4 analog axes, one 8-way digital hat switch position, and up
to 32 button states at a time.
.. code :: cpp
void joy
pad
CB(void *cbdata, int x, int y, int z, int rz, uint8_t hat, uint32_t buttons) {
void joy
stick
CB(void *cbdata, int x, int y, int z, int rz, uint8_t hat, uint32_t buttons) {
// HAT 0 = UP and continues clockwise. If no hat direction it is set to 0x0f.
// Use "buttons & (1 << buttonNumber)" to look at the individual button states
// ...
...
...
@@ -147,7 +147,7 @@ BluetoothHIDMaster::onXXX Callback Installers
void BluetoothHIDMaster::onKeyUp(void (*)(void *, int), void *cbData = nullptr);
void BluetoothHIDMaster::onConsumerKeyDown(void (*)(void *, int), void *cbData = nullptr);
void BluetoothHIDMaster::onConsumerKeyUp(void (*)(void *, int), void *cbData = nullptr);
void BluetoothHIDMaster::onJoy
pad
(void (*)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData = nullptr);
void BluetoothHIDMaster::onJoy
stick
(void (*)(void *, int, int, int, int, uint8_t, uint32_t), void *cbData = nullptr);
BluetoothHIDMaster Class
------------------------
...
...
@@ -187,7 +187,7 @@ bool BluetoothHIDMaster::connect(const uint8_t *addr)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
bool BluetoothHIDMaster::connectKeyboard(), connectMouse(), connectJoy
pad
(), connectAny()
bool BluetoothHIDMaster::connectKeyboard(), connectMouse(), connectJoy
stick
(), connectAny()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
...
...
libraries/BluetoothHIDMaster/examples/KeyboardPiano/KeyboardPiano.ino
View file @
f2729955
...
...
@@ -159,7 +159,7 @@ void ckb(void *cbdata, int key) {
// Joystick can get reports of 4 analog axes, 1 d-pad bitfield, and up to 32 buttons
// Axes and hats that aren't reported by the
pad
are read as 0
// Axes and hats that aren't reported by the
joystick
are read as 0
void
joy
(
void
*
cbdata
,
int
x
,
int
y
,
int
z
,
int
rz
,
uint8_t
hat
,
uint32_t
buttons
)
{
(
void
)
cbdata
;
const
char
*
hats
[
16
]
=
{
"U"
,
"UR"
,
"R"
,
"DR"
,
"D"
,
"DL"
,
"L"
,
"UL"
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
"."
};
...
...
@@ -202,7 +202,7 @@ void setup() {
hid
.
onConsumerKeyDown
(
ckb
,
(
void
*
)
true
);
hid
.
onConsumerKeyUp
(
ckb
,
(
void
*
)
false
);
hid
.
onJoy
pad
(
joy
);
hid
.
onJoy
stick
(
joy
);
hid
.
begin
();
...
...
libraries/BluetoothHIDMaster/examples/KeyboardPianoBLE/KeyboardPianoBLE.ino
View file @
f2729955
...
...
@@ -158,7 +158,7 @@ void ckb(void *cbdata, int key) {
}
// Joystick can get reports of 4 analog axes, 1 d-pad bitfield, and up to 32 buttons
// Axes and hats that aren't reported by the
pad
are read as 0
// Axes and hats that aren't reported by the
joystick
are read as 0
void
joy
(
void
*
cbdata
,
int
x
,
int
y
,
int
z
,
int
rz
,
uint8_t
hat
,
uint32_t
buttons
)
{
(
void
)
cbdata
;
const
char
*
hats
[
16
]
=
{
"U"
,
"UR"
,
"R"
,
"DR"
,
"D"
,
"DL"
,
"L"
,
"UL"
,
""
,
""
,
""
,
""
,
""
,
""
,
""
,
"."
};
...
...
@@ -202,7 +202,7 @@ void setup() {
hid
.
onConsumerKeyDown
(
ckb
,
(
void
*
)
true
);
hid
.
onConsumerKeyUp
(
ckb
,
(
void
*
)
false
);
hid
.
onJoy
pad
(
joy
);
hid
.
onJoy
stick
(
joy
);
hid
.
begin
(
true
);
...
...
libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.cpp
View file @
f2729955
...
...
@@ -161,9 +161,9 @@ void BluetoothHIDMaster::onConsumerKeyUp(void (*cb)(void *, int), void *cbData)
_consumerKeyUpData
=
cbData
;
}
void
BluetoothHIDMaster
::
onJoy
pad
(
void
(
*
cb
)(
void
*
,
int
,
int
,
int
,
int
,
uint8_t
,
uint32_t
),
void
*
cbData
)
{
_joy
pad
CB
=
cb
;
_joy
pad
Data
=
cbData
;
void
BluetoothHIDMaster
::
onJoy
stick
(
void
(
*
cb
)(
void
*
,
int
,
int
,
int
,
int
,
uint8_t
,
uint32_t
),
void
*
cbData
)
{
_joy
stick
CB
=
cb
;
_joy
stick
Data
=
cbData
;
}
std
::
list
<
BTDeviceInfo
>
BluetoothHIDMaster
::
scan
(
uint32_t
mask
,
int
scanTimeSec
,
bool
async
)
{
...
...
@@ -257,7 +257,7 @@ bool BluetoothHIDMaster::connectMouse() {
return
connectCOD
(
0x2580
);
}
bool
BluetoothHIDMaster
::
connectJoy
pad
()
{
bool
BluetoothHIDMaster
::
connectJoy
stick
()
{
return
connectCOD
(
0x2508
);
}
...
...
@@ -427,8 +427,8 @@ void BluetoothHIDMaster::hid_host_handle_interrupt_report(btstack_hid_parser_t *
if
(
updMouse
&&
_mouseMoveCB
)
{
_mouseMoveCB
(
_mouseMoveData
,
dx
,
dy
,
dwheel
);
}
if
(
updJoy
&&
_joy
pad
CB
)
{
_joy
padCB
(
_joypad
Data
,
dx
,
dy
,
dz
,
rz
,
hat
,
newMB
);
if
(
updJoy
&&
_joy
stick
CB
)
{
_joy
stickCB
(
_joystick
Data
,
dx
,
dy
,
dz
,
rz
,
hat
,
newMB
);
}
}
...
...
libraries/BluetoothHIDMaster/src/BluetoothHIDMaster.h
View file @
f2729955
/*
Bluetooth HID Master class, can connect to keyboards, mice, and joy
pad
s
Bluetooth HID Master class, can connect to keyboards, mice, and joy
stick
s
Works with Bluetooth Classic and BLE devices
Copyright (c) 2024 Earle F. Philhower, III <earlephilhower@yahoo.com>
...
...
@@ -78,7 +78,7 @@ public:
static
const
uint32_t
keyboard_cod
=
0x2540
;
static
const
uint32_t
mouse_cod
=
0x2540
;
static
const
uint32_t
joy
pad
_cod
=
0x2508
;
static
const
uint32_t
joy
stick
_cod
=
0x2508
;
static
const
uint32_t
any_cod
=
0
;
std
::
list
<
BTDeviceInfo
>
scan
(
uint32_t
mask
,
int
scanTimeSec
=
5
,
bool
async
=
false
);
bool
scanAsyncDone
();
...
...
@@ -87,7 +87,7 @@ public:
bool
connect
(
const
uint8_t
*
addr
);
bool
connectKeyboard
();
bool
connectMouse
();
bool
connectJoy
pad
();
bool
connectJoy
stick
();
bool
connectAny
();
bool
connectBLE
(
const
uint8_t
*
addr
,
int
addrType
);
...
...
@@ -102,7 +102,7 @@ public:
void
onKeyUp
(
void
(
*
)(
void
*
,
int
),
void
*
cbData
=
nullptr
);
void
onConsumerKeyDown
(
void
(
*
)(
void
*
,
int
),
void
*
cbData
=
nullptr
);
void
onConsumerKeyUp
(
void
(
*
)(
void
*
,
int
),
void
*
cbData
=
nullptr
);
void
onJoy
pad
(
void
(
*
)(
void
*
,
int
,
int
,
int
,
int
,
uint8_t
,
uint32_t
),
void
*
cbData
=
nullptr
);
void
onJoy
stick
(
void
(
*
)(
void
*
,
int
,
int
,
int
,
int
,
uint8_t
,
uint32_t
),
void
*
cbData
=
nullptr
);
private:
bool
_ble
=
false
;
...
...
@@ -135,8 +135,8 @@ private:
void
(
*
_consumerKeyUpCB
)(
void
*
,
int
)
=
nullptr
;
void
*
_consumerKeyUpData
;
void
(
*
_joy
pad
CB
)(
void
*
,
int
,
int
,
int
,
int
,
uint8_t
,
uint32_t
)
=
nullptr
;
void
*
_joy
pad
Data
;
void
(
*
_joy
stick
CB
)(
void
*
,
int
,
int
,
int
,
int
,
uint8_t
,
uint32_t
)
=
nullptr
;
void
*
_joy
stick
Data
;
btstack_packet_callback_registration_t
_sm_event_callback_registration
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment