Skip to content

Commit 30aead9

Browse files
Separate USB gamepad16 report and descriptor (#3263)
Fixes #3262 BTStack redefines many USB HID definitions, so need to be careful to not include full tusb.h before btstack.h. Keyboard and Mouse didn't need special report structs, but Joystick (joystick16) did, so it was including TUSB and BTstack and barfing. Separate the joystick report struct definition from the HID descriptor to avoid the issue.
1 parent 96cbfce commit 30aead9

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

cores/rp2040/sdkoverride/tusb_gamepad16.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,4 @@
6262
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
6363
HID_COLLECTION_END \
6464

65-
// HID Gamepad Protocol Report.
66-
typedef struct TU_ATTR_PACKED {
67-
int16_t x; ///< Delta x movement of left analog-stick
68-
int16_t y; ///< Delta y movement of left analog-stick
69-
int16_t z; ///< Delta z movement of right analog-joystick
70-
int16_t rz; ///< Delta Rz movement of right analog-joystick
71-
int16_t rx; ///< Delta Rx movement of analog left trigger
72-
int16_t ry; ///< Delta Ry movement of analog right trigger
73-
uint8_t hat; ///< Buttons mask for currently pressed buttons in the DPad/hat
74-
uint32_t buttons; ///< Buttons mask for currently pressed buttons
75-
} hid_gamepad16_report_t;
65+
#include "tusb_gamepad16_report.h"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
// HID Gamepad Protocol Report.
6+
typedef struct TU_ATTR_PACKED {
7+
int16_t x; ///< Delta x movement of left analog-stick
8+
int16_t y; ///< Delta y movement of left analog-stick
9+
int16_t z; ///< Delta z movement of right analog-joystick
10+
int16_t rz; ///< Delta Rz movement of right analog-joystick
11+
int16_t rx; ///< Delta Rx movement of analog left trigger
12+
int16_t ry; ///< Delta Ry movement of analog right trigger
13+
uint8_t hat; ///< Buttons mask for currently pressed buttons in the DPad/hat
14+
uint32_t buttons; ///< Buttons mask for currently pressed buttons
15+
} hid_gamepad16_report_t;

libraries/Joystick/src/Joystick.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "tusb.h"
2929
#include "class/hid/hid_device.h"
30+
#include <sdkoverride/tusb_gamepad16.h>
3031

3132
static const uint8_t desc_hid_report_joystick[] = { TUD_HID_REPORT_DESC_GAMEPAD16(HID_REPORT_ID(1)) };
3233

libraries/Joystick/src/Joystick.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#endif
2626

2727
#include <HID_Joystick.h>
28-
#include <class/hid/hid.h>
2928

3029
//======================================================================
3130
class Joystick_ : public HID_Joystick {

0 commit comments

Comments
 (0)