Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Joystick lag #1026
The following problems are exhibited in both the example joystick programs, as well as my own code.
I have three controllers. One exhibits no problems. With two of them, there are frequent random delays in input changes (axes and button presses) being recognised – delays of about half a second. I will write more about the fourth controller later. I have tested all the controllers with Windows 10's "Set up USB game controllers", and they all respond immediately with no lag. They all also work fine in Allegro 4. I have not yet found another game which exhibits the delay.
The only controller which operates with no lag 100% of the time is this:
The second controller, which does have the random lag, is this:
The third controller, which also has the lag, is:
I did some investigation and found a connection with joydx_scan. Changing the frequency by which joysticks are re-scanned changes the interval between each incident of lag. I did some profiling and found that IDirectInput8_EnumDevices always takes about 0.4 seconds (regardless of which controller is attached). If I unplug my keyboard, mouse and graphics tablet, that number drops to about 0.2s, and the lag seems noticeably better. But this doesn't explain why the XInput controller shows no lag at all. On a different PC, which doesn't show the lag issue, that number is around 0.03s.
I have confirmed that the time taken by IDirectInput8_EnumDevices is not due to any code in joystick_enum_callback. Each controller returns from that function near the top (either in the 'Filtered out XInput device' block or the 'Device still exists' block.
I have three questions:
Allegro 5 uses a different driver for XInput joysticks on Windows. That is why you don't get any lag for the XInput joystick. I happen to have written that driver ;) Unfortunately I can't help you with problems in the DirectX driver since I don't know that one too well...