|
|
|
@ -193,18 +193,13 @@ static void removeJoystick(_GLFWjoydeviceNS* joystick) |
|
|
|
|
|
|
|
|
|
// Polls for joystick events and updates GLFW state |
|
|
|
|
// |
|
|
|
|
static void pollJoystickEvents(void) |
|
|
|
|
{ |
|
|
|
|
int joy; |
|
|
|
|
|
|
|
|
|
for (joy = 0; joy <= GLFW_JOYSTICK_LAST; joy++) |
|
|
|
|
static GLFWbool pollJoystickEvents(_GLFWjoydeviceNS* joystick) |
|
|
|
|
{ |
|
|
|
|
CFIndex i; |
|
|
|
|
int buttonIndex = 0; |
|
|
|
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy; |
|
|
|
|
|
|
|
|
|
if (!joystick->present) |
|
|
|
|
continue; |
|
|
|
|
return GLFW_FALSE; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < CFArrayGetCount(joystick->buttonElements); i++) |
|
|
|
|
{ |
|
|
|
@ -251,7 +246,8 @@ static void pollJoystickEvents(void) |
|
|
|
|
joystick->buttons[buttonIndex++] = GLFW_RELEASE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return GLFW_TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Callback for user-initiated joystick addition |
|
|
|
@ -466,18 +462,14 @@ void _glfwTerminateJoysticksNS(void) |
|
|
|
|
|
|
|
|
|
int _glfwPlatformJoystickPresent(int joy) |
|
|
|
|
{ |
|
|
|
|
pollJoystickEvents(); |
|
|
|
|
|
|
|
|
|
return _glfw.ns_js.devices[joy].present; |
|
|
|
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy; |
|
|
|
|
return pollJoystickEvents(joystick); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const float* _glfwPlatformGetJoystickAxes(int joy, int* count) |
|
|
|
|
{ |
|
|
|
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy; |
|
|
|
|
|
|
|
|
|
pollJoystickEvents(); |
|
|
|
|
|
|
|
|
|
if (!joystick->present) |
|
|
|
|
if (!pollJoystickEvents(joystick)) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
*count = (int) CFArrayGetCount(joystick->axisElements); |
|
|
|
@ -487,10 +479,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count) |
|
|
|
|
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count) |
|
|
|
|
{ |
|
|
|
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy; |
|
|
|
|
|
|
|
|
|
pollJoystickEvents(); |
|
|
|
|
|
|
|
|
|
if (!joystick->present) |
|
|
|
|
if (!pollJoystickEvents(joystick)) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
*count = (int) CFArrayGetCount(joystick->buttonElements) + |
|
|
|
@ -500,8 +489,10 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count) |
|
|
|
|
|
|
|
|
|
const char* _glfwPlatformGetJoystickName(int joy) |
|
|
|
|
{ |
|
|
|
|
pollJoystickEvents(); |
|
|
|
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy; |
|
|
|
|
if (!pollJoystickEvents(joystick)) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
return _glfw.ns_js.devices[joy].name; |
|
|
|
|
return joystick->name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|