[hal] Fix joystick buttons not working on SC (#7980)

This commit is contained in:
Thad House
2025-05-18 07:03:52 -07:00
committed by GitHub
parent 231ec348fe
commit 0cb4df7e05
6 changed files with 13 additions and 13 deletions

View File

@@ -22,7 +22,7 @@ static const uint8_t file_descriptor[] {
0x28,0x0d,0x52,0x0b,0x42,0x75,0x74,0x74,0x6f,0x6e,
0x43,0x6f,0x75,0x6e,0x74,0x12,0x18,0x0a,0x07,0x42,
0x75,0x74,0x74,0x6f,0x6e,0x73,0x18,0x02,0x20,0x01,
0x28,0x07,0x52,0x07,0x42,0x75,0x74,0x74,0x6f,0x6e,
0x28,0x04,0x52,0x07,0x42,0x75,0x74,0x74,0x6f,0x6e,
0x73,0x12,0x12,0x0a,0x04,0x41,0x78,0x65,0x73,0x18,
0x03,0x20,0x03,0x28,0x11,0x52,0x04,0x41,0x78,0x65,
0x73,0x12,0x1a,0x0a,0x08,0x50,0x4f,0x56,0x43,0x6f,
@@ -140,12 +140,12 @@ static const uint8_t file_descriptor[] {
0x0a,0x05,0x04,0x00,0x02,0x00,0x01,0x12,0x03,0x07,
0x0b,0x16,0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,0x00,
0x03,0x12,0x03,0x07,0x19,0x1a,0x0a,0x0b,0x0a,0x04,
0x04,0x00,0x02,0x01,0x12,0x03,0x08,0x04,0x18,0x0a,
0x04,0x00,0x02,0x01,0x12,0x03,0x08,0x04,0x17,0x0a,
0x0c,0x0a,0x05,0x04,0x00,0x02,0x01,0x05,0x12,0x03,
0x08,0x04,0x0b,0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,
0x01,0x01,0x12,0x03,0x08,0x0c,0x13,0x0a,0x0c,0x0a,
0x05,0x04,0x00,0x02,0x01,0x03,0x12,0x03,0x08,0x16,
0x17,0x0a,0x0b,0x0a,0x04,0x04,0x00,0x02,0x02,0x12,
0x08,0x04,0x0a,0x0a,0x0c,0x0a,0x05,0x04,0x00,0x02,
0x01,0x01,0x12,0x03,0x08,0x0b,0x12,0x0a,0x0c,0x0a,
0x05,0x04,0x00,0x02,0x01,0x03,0x12,0x03,0x08,0x15,
0x16,0x0a,0x0b,0x0a,0x04,0x04,0x00,0x02,0x02,0x12,
0x03,0x09,0x04,0x1d,0x0a,0x0c,0x0a,0x05,0x04,0x00,
0x02,0x02,0x04,0x12,0x03,0x09,0x04,0x0c,0x0a,0x0c,
0x0a,0x05,0x04,0x00,0x02,0x02,0x05,0x12,0x03,0x09,

View File

@@ -21,7 +21,7 @@ typedef struct _mrc_proto_ProtobufJoystickData {
static pb_filedesc_t file_descriptor(void) noexcept;
uint32_t ButtonCount;
uint32_t Buttons;
uint64_t Buttons;
pb_callback_t Axes;
/* Each POV takes up 4 bits
We can fit 8 in here. */
@@ -155,7 +155,7 @@ typedef struct _mrc_proto_ProtobufAvailableOpModes {
/* Struct field encoding specification for nanopb */
#define mrc_proto_ProtobufJoystickData_FIELDLIST(X, a) \
X(a, STATIC, SINGULAR, UINT32, ButtonCount, 1) \
X(a, STATIC, SINGULAR, FIXED32, Buttons, 2) \
X(a, STATIC, SINGULAR, UINT64, Buttons, 2) \
X(a, CALLBACK, REPEATED, SINT32, Axes, 3) \
X(a, STATIC, SINGULAR, UINT32, POVCount, 4) \
X(a, STATIC, SINGULAR, UINT32, POVs, 5)

View File

@@ -151,7 +151,7 @@ bool wpi::Protobuf<mrc::Joystick>::Pack(OutputStream& Stream,
wpi::PackCallback AxesCb{Value.Axes.Axes()};
uint32_t PovsStore = 0;
for (size_t i = 0; i < Value.Povs.GetCount(); i++) {
for (int i = static_cast<int>(Value.Povs.GetCount()) - 1; i >= 0; i--) {
PovsStore <<= 4;
PovsStore |= Value.Povs.Povs()[i] & 0xF;
}

View File

@@ -256,8 +256,8 @@ void JoystickDataCache::Update(const mrc::ControlData& data) {
povs[count].povs[i] = newPovs[i];
}
buttons->count = newStick.Buttons.GetCount();
buttons->buttons = newStick.Buttons.Buttons;
buttons[count].count = newStick.Buttons.GetCount();
buttons[count].buttons = newStick.Buttons.Buttons;
}
}

View File

@@ -88,7 +88,7 @@ struct JoystickPovs {
};
struct JoystickButtons {
uint32_t Buttons;
uint64_t Buttons;
void SetCount(uint8_t NewCount) {
Count = (std::min)(NewCount, static_cast<uint8_t>(MRC_MAX_NUM_BUTTONS));

View File

@@ -6,7 +6,7 @@ option java_package = "com.mrc.proto";
message ProtobufJoystickData {
uint32 ButtonCount = 1;
fixed32 Buttons = 2;
uint64 Buttons = 2;
repeated sint32 Axes = 3;
// Each POV takes up 4 bits
// We can fit 8 in here.