mirror of
https://github.com/gwm17/glfw.git
synced 2025-02-07 06:38:50 -05:00
Only poll requested joystick on OS X
This commit is contained in:
parent
45efb935c5
commit
12871db0f9
|
@ -193,18 +193,13 @@ static void removeJoystick(_GLFWjoydeviceNS* joystick)
|
||||||
|
|
||||||
// Polls for joystick events and updates GLFW state
|
// Polls for joystick events and updates GLFW state
|
||||||
//
|
//
|
||||||
static void pollJoystickEvents(void)
|
static GLFWbool pollJoystickEvents(_GLFWjoydeviceNS* joystick)
|
||||||
{
|
|
||||||
int joy;
|
|
||||||
|
|
||||||
for (joy = 0; joy <= GLFW_JOYSTICK_LAST; joy++)
|
|
||||||
{
|
{
|
||||||
CFIndex i;
|
CFIndex i;
|
||||||
int buttonIndex = 0;
|
int buttonIndex = 0;
|
||||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
|
||||||
|
|
||||||
if (!joystick->present)
|
if (!joystick->present)
|
||||||
continue;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
for (i = 0; i < CFArrayGetCount(joystick->buttonElements); i++)
|
for (i = 0; i < CFArrayGetCount(joystick->buttonElements); i++)
|
||||||
{
|
{
|
||||||
|
@ -251,7 +246,8 @@ static void pollJoystickEvents(void)
|
||||||
joystick->buttons[buttonIndex++] = GLFW_RELEASE;
|
joystick->buttons[buttonIndex++] = GLFW_RELEASE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback for user-initiated joystick addition
|
// Callback for user-initiated joystick addition
|
||||||
|
@ -466,18 +462,14 @@ void _glfwTerminateJoysticksNS(void)
|
||||||
|
|
||||||
int _glfwPlatformJoystickPresent(int joy)
|
int _glfwPlatformJoystickPresent(int joy)
|
||||||
{
|
{
|
||||||
pollJoystickEvents();
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||||
|
return pollJoystickEvents(joystick);
|
||||||
return _glfw.ns_js.devices[joy].present;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||||
{
|
{
|
||||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||||
|
if (!pollJoystickEvents(joystick))
|
||||||
pollJoystickEvents();
|
|
||||||
|
|
||||||
if (!joystick->present)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*count = (int) CFArrayGetCount(joystick->axisElements);
|
*count = (int) CFArrayGetCount(joystick->axisElements);
|
||||||
|
@ -487,10 +479,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||||
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||||
{
|
{
|
||||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||||
|
if (!pollJoystickEvents(joystick))
|
||||||
pollJoystickEvents();
|
|
||||||
|
|
||||||
if (!joystick->present)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*count = (int) CFArrayGetCount(joystick->buttonElements) +
|
*count = (int) CFArrayGetCount(joystick->buttonElements) +
|
||||||
|
@ -500,8 +489,10 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||||
|
|
||||||
const char* _glfwPlatformGetJoystickName(int joy)
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user