Skip to content

Commit

Permalink
[hal] Fix joysticks either crashing or returning 0 (wpilibsuite#4570)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Nov 5, 2022
1 parent 2c20fd0 commit 837415a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hal/src/main/native/athena/FRCDriverStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
static_assert(sizeof(int32_t) >= sizeof(int),
"FRC_NetworkComm status variable is larger than 32 bits");

namespace {
struct HAL_JoystickAxesInt {
int16_t count;
int16_t axes[HAL_kMaxJoystickAxes];
};
} // namespace

namespace {
struct JoystickDataCache {
Expand Down Expand Up @@ -57,10 +59,11 @@ static wpi::mutex msgMutex;

static int32_t HAL_GetJoystickAxesInternal(int32_t joystickNum,
HAL_JoystickAxes* axes) {
JoystickAxes_t netcommAxes;
HAL_JoystickAxesInt netcommAxes;

int retVal = FRC_NetworkCommunication_getJoystickAxes(
joystickNum, &netcommAxes, HAL_kMaxJoystickAxes);
joystickNum, reinterpret_cast<JoystickAxes_t*>(&netcommAxes),
HAL_kMaxJoystickAxes);

// copy integer values to double values
axes->count = netcommAxes.count;
Expand Down

0 comments on commit 837415a

Please sign in to comment.