Multi-Platform Gamepad Firmware for RP2040
Latency testing methodology and results
This section provides a transparent overview of how we do latency testing for the GP2040-CE project. It includes information about the hardware setup we use, our results, as well has how we calculate our results.
We encourage others to test via these methods and get in touch if they find major differences in results.
The setup used for testing is comprised of an Sunfounder Arduino MEGA 2560 with a generic USB Host Shield addon and an RP2040 Advanced Breakout Board v5.4E Passthrough Edition. The RP2040 Advanced Breakout Board v5.4E Passthrough Edition is connected to the USB Host Shield addon with a 3.3' Ugreen USB-C to USB-A cable. The USB Host Shield addon is connected to the Ardunio MEGA 2560 directly via available header stack. The Arduino MEGA 2560 is connected to an M1 MacBook Air with a 3' Ugreen USB-C to USB-B cable. A 1' female to female DuPont wire is connected between pin 7 on the USB Host Shield, and pin 19 on the RP2040 Advanced Breakout Board v5.4E Passthrough Edition's 20 pin header. This is the `up` direction by default. No other wires or cables are needed.
Serial monitoring can be done via a number of programs. I use `CoolTerm` for serial monitoring on the M1 MacBook Air because it allows me to copy and past result sets easily.
Links to everything mentioned above can be found below:
- Arduino MEGA 2560 Link
- USB Host Shield Link
- RP2040 Advanced Breakout Board v5.4E Passthrough Edition Link
- USB-C to USB-A 3.3' cable Link
- USB-C to USB-B 3' cable Link
- Female to female Dupont wire Link
A copy of the optimized USB Lag sketch we use can be found HERE in our latency_testing folder directly, or can be downloaded from FeralAI's original repo HERE. We follow the methodology and setup outlined by inputlag.science which can be found HERE.
The changes in this optimized version of the USB Lag sketch are:
- Tuned core input loop logic to reduce unnecessary overhead - Test results will be around ~0.1ms faster than the original sketch, and very close to the results from the MiSTer Input Latency Tester Link
- See test results immediately after the test, by pressing =
By default the optimized USB Lag sketch will run a series of 1,000 inputs and measure their latency. We have found through testing that there can be very small variances in results when comparing sets of 1,000 input tests. As such, we run the optimized USB Lag sketch 10 times in a row, and average the averages of each set of 1,000 individual tests, to come up with our overall average latency. It is important to note that we still look at the overall highest latency input as our high number, and the lowest overall low latency input as our low number. We do not average solely from these two results.
It is also important to note that these 10 runs of 1,000 input tests are always conducted back-to-back. We do not cherry pick good runs. Doing so could lead to a deflated and unrealistic overall average latency number.