Arduino Project to measure USB Controller input lag...optimized.
This is an optimized version of the original lag testing sketch by Loïc WydD Petit. The original version can be found on here: https://gitlab.com/loic.petit/usblag. The remaining README content is directly from the original repository.
You need a arduino board with a USB Host Shield properly installed.
Note: if you own a rev1 board (not ICSP connector) be sure to check out the hardware manual to bind the four signals to the right pins.
After that, hook up the desired button signal using the necessary protection like an inverted diode to pin 7 and you're good to go.
Assuming that you have the Arduino IDE, just install the library USB Host Shield Library 2.0 in the Tools > Manage Libraries section. After that, upload the sketch to the board, and open the serial monitor.
This contains extra-minimal drivers for HID compliant devices and standard XInput devices (maybe not the latest xbox one stuff thought). Don't hesitate to create an MR if one of your device is not supported.
This program may or may not support hotplugs so be sure to hit the reset button if you switch you device.
The serial monitor will support different commands to play with your device:
command | effect |
---|---|
0 | Set the button signal to False |
1 | Set the button signal to True |
t | Fire a test of 1000 data points |
o | Override polling interval to 1ms |
2 | Override polling interval to 2ms |
4 | Override polling interval to 4ms |
8 | Override polling interval to 8ms |
p | Override polling interval like a PC would do |
n | Set the polling interval back to normal |
sX | Override polling interval to Xms |
= | Displays min/max/avg/stddev from test |
- Connect your device
- Reset the arduino to be sure
- Note the polling interval
- Try command 0 and 1 to see if you signal is properly routed to your board. If it works you should see a lag value in ms.
- Clear output
- Send the command t... wait
- Change the polling interval at will and do the experiment again
Don't hesitate to use the google spreadsheet to analyze the results.
The drivers code are mainly built on extracted code from the USB Host Shield Library 2.0, licenced using GPL2.
The rest of the code is under the MIT Licence.