From 837415abfd834648124fb54b409077d8d15b2751 Mon Sep 17 00:00:00 2001 From: Thad House Date: Fri, 4 Nov 2022 19:03:11 -0700 Subject: [PATCH] [hal] Fix joysticks either crashing or returning 0 (#4570) --- hal/src/main/native/athena/FRCDriverStation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hal/src/main/native/athena/FRCDriverStation.cpp b/hal/src/main/native/athena/FRCDriverStation.cpp index b9c6c73521..e80f48c0f9 100644 --- a/hal/src/main/native/athena/FRCDriverStation.cpp +++ b/hal/src/main/native/athena/FRCDriverStation.cpp @@ -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 { @@ -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(&netcommAxes), + HAL_kMaxJoystickAxes); // copy integer values to double values axes->count = netcommAxes.count;