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:
Thad House
2016-01-13 21:35:51 -08:00
parent bf89762e82
commit f79ed1ab44

View File

@@ -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;