Well some progress this week, I finally had some time to just sit down and code.
For various reasons I am writing the MFD code for AN/APG – 68 radar, basically I am still working on doing a standalone MFD based on a Raspberry PI with a small display.
I got to the point where I really needed an input device, so I shelled out for a X56 Rhino HOTAS flight stick and throttle.
Amazon were amazing and delivered early the next morning.
I eagerly connected everything up and tested it all, works perfectly. (Little annoyed with the spring on the joystick, but I'm sure I can solve that issue).
So I then wanted to write the code to support it..... which is where everything turned to brown and smelly.
I first went to DirectInput. Does everything I want, simple interface, perfect. DEPRECATED.
Well Microsoft must have replaced it with something, ahh XInput. Great. Nope ... ONLY SUPPORTS XBOX GAMEPADS
Shit. A bit more digging and I found Game.Windows.Input. Perfect.... ONLY SUPPORTED IN UWP
So..... no Windows API's for joysticks anymore. WTF!
Dug around some more and realised I would have to nuke it from orbit and use HID (Human Interface Device Api ). Very low level and ancient. (Has it's origins in Win32).
A full day of coding later I have a HID layer working. HID just returns an array of bytes. So I then have to work out what all those 0's and 1's mean.
After several hours of experimentation, I have mapped the entire HID report and have working code.
So I wrote a test app to confirm it all works in game. And it does.... sort of.
I am starting the update of the HID device on the update thread and reading it in the render thread. So I expected about 50ms of latency. Nope. At first it was over 1000ms. So I dug around in the code and found a mistake, but it's still not great. I am guessing I have around 300ms latency. Not good enough, but will do for now as I am sick of messing around with it.
Now I just need to add it into this code.
Sigh.