Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 6 7   Go Down

Author Topic: Mike's new project  (Read 20196 times)

0 Members and 1 Guest are viewing this topic.

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #24 on: April 18, 2018, 02:17:04 AM »

Alright guys, time to proceed.
Today we see part of the software side.
I'm using MMjoy2 in order to create a Game Controller Device Windows can use.
My controller is a Teensy++ 2.0, it's important to know that MMjoy also supports other controller boards so this setup is just a reference, if you have a different type of controller, several things might be slightly different for you.

The first thing you do in order to create a Game Controller (aka "Joystick") device is to download MMjoy2, extract it and then run "MMJoySetup.exe".
Plug your Arduino (in my case: Teensy++ 2.0) board to a USB hub and put it into bootloader mode (in my case: Press the Reset Switch on the Teensy++ 2.0).
This will get you a "Human Interface Device" with a specific Vendor ID (in case of the Teensy++ 2.0 "16C0") and Product ID (in case of the Teensy++ 2.0 "0478") which you can select as step 1 in MMJoySetup:


Switch to the "Firmware" Tab and proceed with the Firmware file (2).
Firmware files can be found in the folder "Firmware" of MMjoy2, in case of the Teensy++ 2.0 we're using an Atmel 90USB1286 chipset, therefore the Firmware file to choose is "Firmware_lufa_[MMJOY2.AT90USB1286].hex". If you use a different board, choose the firmware that matches your board's chipset.
In the "Chip" dropdown list choose the chipset accordingly.
In the "Bootloader type" dropdown you either have to choose "Arduino" or - in case of Teensy boards like mine - Teensy. If you choose "Arduino", you likely have to set a COM port in the following box, but I have no personal experience with this - Google is your friend.

Finally, click "Upload Firmware" which should flash a DOS box briefly, and then you board will be re-attached to USB with a different ID:


If everything went well with the Firmware Upload, you will now find your board attached as "MMJ-reset" with VID and PID "8888" (1).
At 2 you can setup your own VID, PID and name for your Joystick Device.
The trick about VID and PID is that when multiple Game Controllers are attached to your Windows PC at boot time, they will be enumerated according to their VID and PID, meaning that if e.g. you set both values to "0001" your device will always be Joystick No.1, whereas of you turn them into "FFFF" it will always be the last joystick.

Now switch to the "Joystick axes" Tab:


"Source" (1) defines the type of Sensor. In my case I'm using simple Potentiometers, those are type "Internal".
"MCU Port" (2) defines the pin where your Sensor (here Poti) is attached.
"Assignment" (3) defines the logical Joystick Axis this Sensor should represent.
"Precision (bit)" (4) is usually "10" for Potis. For higher precision you need external A/D converters.
"Filter" (5) defines the Filter to be applied. The lower the value, the faster the reaction of your Sensor and the more distinct values you get. The higher the value, the more you can eliminate "Spikes" in the Sensor readout.
"Auto-calibration" (6) defines what it says. In my case I don't have "center" values on my Potis, so I'll let it calibrate automatically without any center applied.
Dead Zones (7) define how to deal with extreme values and changes below a certain treshold. We can discuss this separately if you need more explanations about this.

Next is the "Joystick buttons" Tab:


1 is the Button Matrix. I'm using an 8x10 matrix for a total of 80 buttons, consisting of 40 "real" buttons (10 of each color, red-yellow-green-blue) and 20 switches with 2 positions each.
2 is the logical Game Controller Button. You can setup max. 64 controller buttons in MMjoy2, but take care: Windows can read the first 32 of them only, the others have to be converted to keystrokes by a separate software tool - we will deal with this later.
3 is the hardware button on our button matrix.
4 is the mode. "Switch ON" means the logical button will be pressed when the hardware button is, and released if not.
5 is a mapping of hardware buttons to logical keys. I'm using this to get another 8 hardware buttons mapped, and I map them to F17-F24 cause I don't have these keys on my hardware PC keyboard so they're "free".
6 are "Coolie Hat" mappings. I'm using this for the final 8 hardware buttons and map them to 2 logical coolie hats.

When you have assigned everything correctly, it's time to safe the settings to a file (7) and then finally upload it to your board (8).

This will detach and re-attach your board to USB again, and now it turned into a game controller:


If you click on "properties", you will see your axis, the first 32 buttons, and one of the coolie hats:


That's it so far, further fine tuning, assignment of buttons 33-64 and other hardware-mappings will come later.
To be continued...

Cheers!
Mike
Logged
Don't split your mentality without thinking twice.

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #25 on: April 19, 2018, 08:17:18 AM »

Just a small update today.
Due to lack of space and excessive wiring requirements when using the perfboard layout, I've decided to solder most parts like diodes, capacitors etc. directly to the switches, pushbuttons, potis etc.
That safes me from having to implement a perfboard at all, and instead of having to route 120+ wires in the box, I'll only need 18 of them.

This is the circuit diagram, click for scalable SVG vector graphic:


Cheers!
Mike
Logged
Don't split your mentality without thinking twice.

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #26 on: April 27, 2018, 06:29:13 AM »

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
Logged
Don't split your mentality without thinking twice.

SAS~Skylla

  • SAS Team
  • member
  • Offline Offline
  • Posts: 1950
  • Flying Ass Clown N°24
Re: Mike's new project
« Reply #27 on: April 27, 2018, 10:12:30 AM »

thanks a lot for the detailed description of the project status. You should know that - ableit being a little too silent - I follow this project with great interest.

And I don't mind the lack of pictures at all, I had to read through much worse publications :P
Logged
When all else fails: read the instructions!

sniperton

  • member
  • Offline Offline
  • Posts: 1226
Re: Mike's new project
« Reply #28 on: April 27, 2018, 11:44:13 AM »

I follow this project with great interest.

Me too. My only concern is ergonomic, which hand of you is designated to fiddle with so many switches and buttons?
Logged

SAS~GJE52

  • Editor
  • member
  • Offline Offline
  • Posts: 5147
  • Orchard Studios
Re: Mike's new project
« Reply #29 on: April 27, 2018, 07:15:00 PM »

I find this fascinating. Great project.

I have been trying to get 5 USB devices - Joystick, pedals, throttle and 2 MFD's - to work with IL2 46.  The game will only see 4 normally. (plus keyboard and mouse). I have tried a software solution called TARGET that was bundled with the MFD's which claims to allow more devices ..... but it can't seem to see the Saitek rudder pedals. Seeing your designs I wonder if there could be a hardware solution to combine the two MFD's to look like one device..

I shall continue to watch your progress  with interest..

G;
Logged
Do not criticise a man until you have walked a mile in his shoes...  Then you can call him what you like, as you have his shoes ... and he is a mile away......

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #30 on: April 27, 2018, 11:15:46 PM »

Plan change :D
Sometimes you just can't see the wood for all of the trees.
Actually the best solution for me in the long term will be to have the switchbox appear as two independent game devices, each with 3 axis, 32 buttons and one 8-way hat switch, and map the hardware axis, switches and buttons to these.
That way it'll work with any game, and there's even the very same short term solution in software:
Let MMJoy2 make the device appear as 5-axis, 82 button device (remember, buttons 74 and 75 are no-go).
Create two virtual VJoy devices each with 3 axis (one with 3 and one with 2 would be sufficient as well, or one with 5 and one without any), 32 buttons and one 8-way hat switch.
Let Joystick Gremlin map the axis and buttons of the MMJoy2 device to the two VJoy devices.
This will create the very same effect like the long term hardware solution and it will work perfectly fine with both IL-2 Great Battles and IL-2 1946.

which hand of you is designated to fiddle with so many switches and buttons?
I think the general misunderstanding here is that such game devices are always thought to be absolutely intuitive and user friendly.
This one serves the single purpose of providing additional axis for things like radiator, mixture, pitch and maybe some trim settings - simple potentiometers do the trick here because what's most important is that you have a label clearly telling which poti is what.
Similar thing with the switches and buttons: Instead of crawling through books of keyboard settings when you want to do something during flight, this box has labels clearly telling which switch or button is what, so you can toggle/actuate/press it without having to think of where to find the key mapping for what you're just intending to do.
That's the whole idea of this switchbox: Don't search through key mapping lists anymore, read the label and press the button instead.

I have been trying to get 5 USB devices - Joystick, pedals, throttle and 2 MFD's - to work with IL2 46.
The same software combo VJoy + Joystick Gremlin could do the trick too.
With Joystick Gremlin you can map axis, switches, buttons, hats etc. from hardware devices to virtual devices created in VJoy.
That way you can map your 5 USB devices to a single (or 2, 3, 4...) VJoy devices.
The only question is: Will IL-2 1946 see the VJoy devices first, or will the existing hardware devices blank them out?

Maybe I can shed some light on that question later.
VJoy has a "feeder" application to create virtual input to your virtual devices.
So I could prepare a test setup with my X-52 Pro, the Switchbox and 4 VJoy device(s).
Then I'd feed virtual input to VJoy devices 3+4 and check whether IL-2 1946 sees them.
If so, VJoy comes first and "overrides" hardware devices, which would mean that this would do the trick for you.
If not, bad luck. I have no idea whether it's possible to assign a custom VID/PID to VJoy devices - that's what matters most for the order of Joysticks to appear to Windows and with it, to other games.

Cheers!
Mike
Logged
Don't split your mentality without thinking twice.

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #31 on: April 28, 2018, 12:10:52 AM »

Oh man...
Turns out that VJoy, if you create more than one virtual device, inserts all virtual devices at the same time, with same VID/PID, so that windows will randomly sort them at will.
See here: http://vjoystick.sourceforge.net/site/index.php/forum/4-Help/825-strange-behaviour

I've got the same thing: With 4 VJoy devices configured, the device order now is:
  • VJoy device no.2
  • VJoy device no.1
  • VJoy device no.4
  • X-52 Pro
  • Switchbox
  • VJoy device no.3

What a bummer.

Cheers!
Mike
Logged
Don't split your mentality without thinking twice.

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #32 on: April 30, 2018, 08:06:33 AM »

Small Update again.
I've managed to get a clean USB device config working with 32 buttons and 3 hats on the Teensy. No idea why the device fails to get recognized when I add a 4th hat, but that's not an issue to me - 3 are sufficient for my plans.
The next step will be to try to get a 2nd joystick device to be recognized from the same physical thing.

The other (software) solution is working well.
Actually the mixed up device numbering isn't much of an issue.
The order of devices, VJoy and physical ones, stays the same even after reboot. Even if I unplug a hardware device and plug it in later again, it will rejoin at the very same place in the list.
Apparently, regardless how many VJoy devices I configure - all but one will be at the beginning of the list, and one will be at the end.
If it's just one VJoy device, it will always be at the end of the list.
Therefore, if you need to map existing hardware devices to a smaller number of VJoy devices, this will be possible. Just configure one more VJoy device than you actually need, so you have the needed ones in the beginning of the list.
Therefore that seems to be a viable solution for your issue Glynn.
For my purpose it definitely works well.

Cheers!
Mike
Logged
Don't split your mentality without thinking twice.

SAS~GJE52

  • Editor
  • member
  • Offline Offline
  • Posts: 5147
  • Orchard Studios
Re: Mike's new project
« Reply #33 on: April 30, 2018, 08:48:41 AM »

Quote
The order of devices, VJoy and physical ones, stays the same even after reboot. Even if I unplug a hardware device and plug it in later again, it will rejoin at the very same place in the list.
Apparently, regardless how many VJoy devices I configure - all but one will be at the beginning of the list, and one will be at the end.
If it's just one VJoy device, it will always be at the end of the list.
Therefore, if you need to map existing hardware devices to a smaller number of VJoy devices, this will be possible. Just configure one more VJoy device than you actually need, so you have the needed ones in the beginning of the list.
Therefore that seems to be a viable solution for your issue Glynn.
For my purpose it definitely works well.   

Thanks Mike. I will investigate further. If I can use it to combine the two "28 button" MFD units into one effective 56 button device the rest should be OK. Or combine the rudder pedals with the joystick perhaps...

G;
Logged
Do not criticise a man until you have walked a mile in his shoes...  Then you can call him what you like, as you have his shoes ... and he is a mile away......

SAS~Storebror

  • Editor
  • member
  • Offline Offline
  • Posts: 23563
  • Taking a timeout
    • STFU
Re: Mike's new project
« Reply #34 on: April 30, 2018, 09:08:39 AM »

Yes you can.
Per VJoy device you can have up to 8 axis, 128 buttons and 4 "continuous" POV hats (act like 8-way ones in IL-2 1946).
You can also have 11 different Force Feedback Effects if you want to.
There no limit in combining these, so you can definitely merge two 28 button MFD units into one, and you can even add the rudder pedals to it and most probably there's still room to add all joystick buttons and axis to that device too (and if not, no big deal either).
The mapping will be done with Joystick Gremlin.
Joystick Gremlin is a bit hard to get used to, at least it appeared so to me, but once you get around the macro scripts, it can do anything you want.
Remapping simple buttons is a no-brainer, remapping axis too.
Remapping POV hats requires macros but I can show you how that works.

Cheers!
Mike
Logged
Don't split your mentality without thinking twice.

SAS~GJE52

  • Editor
  • member
  • Offline Offline
  • Posts: 5147
  • Orchard Studios
Re: Mike's new project
« Reply #35 on: April 30, 2018, 10:19:25 AM »

Ok, looks very promising...  ;)

Thanks for the offer of help as well. I will do some more research and get back to you.

I just found this "old" thread as well ....
  https://www.sas1946.com/main/index.php/topic,45118.25.html 

Off to search out and DL VJoy now.

G;
Logged
Do not criticise a man until you have walked a mile in his shoes...  Then you can call him what you like, as you have his shoes ... and he is a mile away......
Pages: 1 2 [3] 4 5 6 7   Go Up
 

Page created in 0.069 seconds with 24 queries.