I'm using GLFW to record the states of joysticks in a robotics project, and came across something strange.
On a Macbook Air, running 10.11.3, GLFW only returns the state of the joysticks at the beginning of the program. The documentation claims that it updates the state every time a joystick function is called, however. Using the joystick present and joystick name function only return the original state.
I cannot reveal my code. However, I am using ImGui, and one of it's sample programs should suffice. To reproduce the problem, run the 'opengl3_example' project with these changes:
Right after the line ImGui_ImplGlfwGL3_NewFrame();
, add this:
for (int i = 0; i < 15; i++)
{
if (glfwJoystickPresent(i) != GL_TRUE)
{
printf("There are %d joysticks detected.\n",i); break;
}
}
In my case, if the program starts with no joysticks attached, and one is plugged in after the program has started running, it would claim that there would still be 0 joysticks attached. The problems run beyond that function, as the button and axis states are not updated as well.
I am using the latest GLFW 3.1.2, compiled from source. Please advise me on this.
EDIT: If you want to know what should happen, take a look at the video https://www.youtube.com/watch?v=mx0IUbxAQ34 on the 2:09 timestamp.
EDIT: I've tried a different library, and it detects the joysticks properly.
Thanks in advance.
It turns out that the version of GLFW on homebrew is bugged. What an anticlimax.
For some reason, when I installed from source, it did not override homebrew's installed binaries. This led me to think it was a problem with code.
It wasn't.