@ -377,6 +377,11 @@ void _glfwInputJoystick(_GLFWjoystick* js, int event)
{
const int jid = ( int ) ( js - _glfw . joysticks ) ;
if ( event = = GLFW_CONNECTED )
js - > connected = GLFW_TRUE ;
else if ( event = = GLFW_DISCONNECTED )
js - > connected = GLFW_FALSE ;
if ( _glfw . callbacks . joystick )
_glfw . callbacks . joystick ( jid , event ) ;
}
@ -442,7 +447,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
for ( jid = 0 ; jid < = GLFW_JOYSTICK_LAST ; jid + + )
{
if ( ! _glfw . joysticks [ jid ] . present )
if ( ! _glfw . joysticks [ jid ] . allocated )
break ;
}
@ -450,7 +455,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
return NULL ;
js = _glfw . joysticks + jid ;
js - > present = GLFW_TRUE ;
js - > allocated = GLFW_TRUE ;
js - > axes = _glfw_calloc ( axisCount , sizeof ( float ) ) ;
js - > buttons = _glfw_calloc ( buttonCount + ( size_t ) hatCount * 4 , 1 ) ;
js - > hats = _glfw_calloc ( hatCount , 1 ) ;
@ -972,7 +977,7 @@ GLFWAPI int glfwJoystickPresent(int jid)
return GLFW_FALSE ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return GLFW_FALSE ;
return _glfw . platform . pollJoystick ( js , _GLFW_POLL_PRESENCE ) ;
@ -1000,7 +1005,7 @@ GLFWAPI const float* glfwGetJoystickAxes(int jid, int* count)
return NULL ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return NULL ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_AXES ) )
@ -1032,7 +1037,7 @@ GLFWAPI const unsigned char* glfwGetJoystickButtons(int jid, int* count)
return NULL ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return NULL ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_BUTTONS ) )
@ -1068,7 +1073,7 @@ GLFWAPI const unsigned char* glfwGetJoystickHats(int jid, int* count)
return NULL ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return NULL ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_BUTTONS ) )
@ -1097,7 +1102,7 @@ GLFWAPI const char* glfwGetJoystickName(int jid)
return NULL ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return NULL ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_PRESENCE ) )
@ -1125,7 +1130,7 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
return NULL ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return NULL ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_PRESENCE ) )
@ -1144,7 +1149,7 @@ GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
_GLFW_REQUIRE_INIT ( ) ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > allocated )
return ;
js - > userPointer = pointer ;
@ -1160,7 +1165,7 @@ GLFWAPI void* glfwGetJoystickUserPointer(int jid)
_GLFW_REQUIRE_INIT_OR_RETURN ( NULL ) ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > allocated )
return NULL ;
return js - > userPointer ;
@ -1230,7 +1235,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
for ( jid = 0 ; jid < = GLFW_JOYSTICK_LAST ; jid + + )
{
_GLFWjoystick * js = _glfw . joysticks + jid ;
if ( js - > present )
if ( js - > connected )
js - > mapping = findValidMapping ( js ) ;
}
@ -1256,7 +1261,7 @@ GLFWAPI int glfwJoystickIsGamepad(int jid)
return GLFW_FALSE ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return GLFW_FALSE ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_PRESENCE ) )
@ -1284,7 +1289,7 @@ GLFWAPI const char* glfwGetGamepadName(int jid)
return NULL ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return NULL ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_PRESENCE ) )
@ -1319,7 +1324,7 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
return GLFW_FALSE ;
js = _glfw . joysticks + jid ;
if ( ! js - > present )
if ( ! js - > connected )
return GLFW_FALSE ;
if ( ! _glfw . platform . pollJoystick ( js , _GLFW_POLL_ALL ) )