Small Update again.
Soldering parts to the upper half of the box is nearly finished.
Software is the difficult part...
Turns out that several limitations apply.
IL-2 1946 has a hard limit of 32 joystick buttons.
I've tried to overcome that limit, but it's in native code.
So I thought I could use F13-F24 function keys, but again in native code IL-2 1946 decides to ignore these.
IL-2 Great Battles has a rather irritating limit of 62 buttons (makes no sense, some say it'd be 64, but buttons 63 and 64 aren't working correctly either - from Windows point of view, the limit would be 128 like in DCS).
Function keys 13, 14 and 15 work, 16-24 don't.
Dammit.
What else?
Both games can handle up to 4 POV hat switches with up to 8 positions each - hooray!
However, IL-2 1946 throws all hats from all devices into a single list, meaning that hat no.1 on joystick no.1 is the same as hat no.1 on joystick no.2.
Dammit.
Anyway...
In the long run, I'm still planning to throw a full-featured self-contained firmware onto the device which will deal with this on it's own, but it's a PITA.
The plan would be to switch modes by pressing 4 keys simultaneously (for the sake of simplicity, it would be the 4 coloured buttons at the edge of the matrix) - this works great. I can catch this in software and switch operation modes there.
Then I'd treat the buttons according to the mode selected.
In IL-2 Great Battles Mode, the first 62 switch positions and buttons would be handed to the game as-is, the latter 18 would be handled as 3 independent 8-way hats.
The first part works great, the hat part gives me headaches at the moment, because the arduino USB device descriptors for POV hats contain 4-way hats only (and "continuous 360 degree" hats which aren't working for some reason).
In IL-2 1946 Mode, the first 32 switch positions would be handed to the game as-is, followed by 3x 8-way hats (this is because my X-52 Pro has one hat already, actually even more, but only the first one is recognized as a hat by IL-2 1946, the others are buttons). That'd be 56 out of 80 buttons and switches in total. The remaining 24 would have to be mapped to keystrokes.
Keystrokes work fine, even in combination with modifiers (Shift, Ctrl, Alt), however IL-2 1946 cannot distinguish between left and right modifiers, doesn't know the windows key, and cannot handle multiple modifiers at once.
The biggest headache about my own firmware however is the USB device descriptor and the raw usb protocol behind.
The Arduino sketches use 32 buttons + one 4-way hat only, so I'll have to rewrite the whole USB protocol myself.
While there are proof-of-concept USB decriptors for Teensy 3.x boards available, I'm stuck on my Teensy++ 2.0 and it seems no one did the same here yet.
Unfortunately the USB protocol is vastly different between Teensy 3 and 2, so that's a bit of research which is necessary here.
In the meantime, to get things started, I've followed the path of available tools.
This involves a combination of MMJoy2, VJoy and Joystick Gremlin.
MMJoy2 is available here:
https://sites.google.com/site/mmjoyproject/The site is in russian only, but the other spot where MMJoy2 is available (Github) holds outdated versions only.
When you visit the MMJoy2 site, don't use the currently latest version (at the moment that'd be v20161101), it's bugged. Use the previous one instead (at the moment v20160818upd1).
MMJoy2 enables us to configure all hardware buttons on the switchbox and map them to joystick buttons.
Beware: For some reason, logical buttons 74 and 75 don't work well with MMJoy2, therefore my 80-button (switches and buttons that is) box is configured to use logical buttons 1-73, 76-80, and then 81 and 82 for the hardware buttons 74 and 75. From Windows point of view this gives you an 82-button Joystick where buttons 74&75 will never fire up.
VJoy is available here:
http://vjoystick.sourceforge.net/site/It's required by Joystick Gremlin.
In VJoy you configure your "output" virtual joystick.
The virtual Joystick we create has 62 buttons and 4 8-way hats, plus 5 axis. That's the most we can use with our box in any of the targetted games.
Joystick Gremlin (available here:
https://whitemagic.github.io/JoystickGremlin/) finally maps the input from our hardware switchbox to the virtual joystick of VJoy.
My Gremlin config maps hardware buttons 1-32 straight through, followed by another 32 hardware buttons mapped to the 4 hat switches, and then the remaining buttons mapped straight through again.
That's suitable for IL-2 Great Battles and to some extent for 1946. For the latter I could add a second Gremlin profile but that has to be done later.
That's it for the moment.
Excuse me that I have no pics or config files at the moment, it's all too much WIP - as you see my previous MMJoy2 screenshots, as tedious as it was to create them, were just waste of time.
Cheers!
Mike