Hey Mark, I found a small mistake in 'BBGlfwGame::PollJoystick'... The thing is, the results are terrifying. By changing one line, I went from 100 FPS on the Mojo 2 "Hello world" example to ~3000.
GLFW unfortunately uses the old WinMM API, so calling 'glfwJoystickPresent' ends up being incredibly slow. Now, if this was called once, or on occasion, nobody would care. Except, this line says differently (Applies to GLFW3+ANGLE as well). You're apparently checking if 'port' is 0 or less than zero, which itself is pointless. I assume you meant to accesss 'pjoys', but that would still make this lag until the entire array was full. Checking on occasion, or at 'StartGame' would be a lot better. I'm not sure if that was even structured correctly, but a single call to 'glfwJoystickPresent' takes the framerate on a normal scene from 900+ FPS to somewhere between 80 and 100. Now, when it starts lagging, this becomes a serious time sink. A time sink that could actually be spent on the game, not checking for ~4 joysticks every single frame.
I suggest using a timer based on 'GetTime' (Or doing it asynchronously), that way it's not bottlenecking the entire program. The alternative would be adopting XInput on Windows, something I've already done here.
If you're not willing to fix this, I understand, but is there any chance of publicizing 'mojo.inputdevice' / making an interface? If I was able to make an XInput 'InputDevice' without editing Mojo, this wouldn't really be a problem.
EDIT: I should mention that the other GLFW commands are fine, it's just 'glfwJoystickPresent' that causes major stalls.
|