mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
Artf4800: Fixes HALGetJoystick*** Segfault
The HALGetJoystick*** methods were not initializing the descriptor variable properly. This was causing a SegFault if joysticks were moved around while one of these methods were running. Change-Id: If804c7ea724b10381765068e4d6fad75fad69ecb
This commit is contained in:
@@ -44,6 +44,9 @@ int HALGetJoystickDescriptor(uint8_t joystickNum, HALJoystickDescriptor *desc)
|
||||
int HALGetJoystickIsXbox(uint8_t joystickNum)
|
||||
{
|
||||
HALJoystickDescriptor joystickDesc;
|
||||
joystickDesc.isXbox = 0;
|
||||
joystickDesc.type = -1;
|
||||
joystickDesc.name[0] = '\0';
|
||||
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
||||
{
|
||||
return 0;
|
||||
@@ -56,6 +59,9 @@ int HALGetJoystickIsXbox(uint8_t joystickNum)
|
||||
int HALGetJoystickType(uint8_t joystickNum)
|
||||
{
|
||||
HALJoystickDescriptor joystickDesc;
|
||||
joystickDesc.isXbox = 0;
|
||||
joystickDesc.type = -1;
|
||||
joystickDesc.name[0] = '\0';
|
||||
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
||||
{
|
||||
return -1;
|
||||
@@ -68,6 +74,9 @@ int HALGetJoystickType(uint8_t joystickNum)
|
||||
char* HALGetJoystickName(uint8_t joystickNum)
|
||||
{
|
||||
HALJoystickDescriptor joystickDesc;
|
||||
joystickDesc.isXbox = 0;
|
||||
joystickDesc.type = -1;
|
||||
joystickDesc.name[0] = '\0';
|
||||
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
||||
{
|
||||
char* name = (char*)std::malloc(1);
|
||||
@@ -85,6 +94,9 @@ char* HALGetJoystickName(uint8_t joystickNum)
|
||||
int HALGetJoystickAxisType(uint8_t joystickNum, uint8_t axis)
|
||||
{
|
||||
HALJoystickDescriptor joystickDesc;
|
||||
joystickDesc.isXbox = 0;
|
||||
joystickDesc.type = -1;
|
||||
joystickDesc.name[0] = '\0';
|
||||
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
||||
{
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user