mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Currently, about 5ms of every 20ms loop the DS thread would hold the mutex, while grabbing data. During this time, and call to grab joystick data would be blocked. This change grabs the joystick data to a cache, and then grabs the mutex and moves the data references around. This is much more efficient then the old code, and gives teams more of their teleop loop time back for use. Another major change this does is use preallocated arrays when entering the JNI. Previously every JNI DS call would allocate an entire new array. With a GC'd language where those arrays go on the heap, thats a problem, and creates tons of garbage. That garbage is no longer created anymore, as all arrays and byte buffers sent to JNI in the DS are preallocated. In addition, GetJoystickName was always returning joystick 0 data, which this fixes.