Jump to content

How to set up toggle switches (a tutorial)


Recommended Posts

Well, I've read through this thread and have and understanding on how to edit the default Lua as per the post on Page 15 at the top.

 

I've run into a little problem and was wondering what I'm missing.

 

I have an 'On/Off/On switch that I'm trying to use for the 'Position Flash, Off, Steady' switch in the A10c.

 

Here is the code I used:

{down = 3008, value_down = 1, up = 3008, value_up = 0, cockpit_device_id = 49, name = _('ALT Position Flash'), category = _('Lighting Panel')},

 

{down = 3008, value_down = 1, up = 3008, value_up = 0, cockpit_device_id = 49, name = _('ALT Steady'), category = _('Lighting Panel')},

 

The first line works great, the switch moves just like I want. The second command doesn't show up inside the A10 options at all.

 

Any help would be appreciated, as I have a Master Arm, Gun/Pac, Laser Arm, and Autopilot switches to program, I need to learn this stuff.

Link to comment
Share on other sites

  • 2 months later...

Add the line in the "Throttle - HOTAS Warthog.lua" not the default.lua

 

Also by using Icommands you don't get optimal synchronicity. say for instance your switch is set to up and in game its down. Then when you set the switch to down the ingame switch goes to up.

 

Best way to do it is by going in clickable lua and finding out what Button number it is for instance 3002. What device number it is and what the states are: 1.0, 0.5, 0.0 etc.

 

Then a simple value_up = 1.0 and value_down = 0.0

 

As I have the Ka-50 as well here is my code for the laser off/on:

 

{down = iCommandPlaneLaserRangerOnOff, name = _('Laser standby On/Off switch'), category = _('Ins Targeting Mode Controls Panel PVR')},
{down = 3001, value_down = 1, up = 3001, value_up = 0, cockpit_device_id = 11, name = _(' Laser standby On/Off switch'), category = _('Ins Targeting Mode Controls Panel PVR')},

Find the first line and then add the second line beneath that in the "Throttle - HOTAS Warthog.lua"

 

 

Hey I tried your method but, when I go into the game, I can only assign the alternate button to my first joystick, see the screen :

controls_dcs.jpg

cjxepbzb1


Edited by kingpinda
Link to comment
Share on other sites

  • 1 month later...

Not sure what I'm doing wrong here. My .lua files look completely different than the ones here. The code appears like this:

 

 

        ["d3004pnilunilcd1vd1vpnilvunil"] = {
           ["added"] = {
               [1] = {
                   ["key"] = "JOY_BTN20",
               },
           },
           ["name"] = "Engine Master Switch - ON",
       },

 

Has the lua format changed since this guide was written?

Link to comment
Share on other sites

You are looking at the .diff.lua

That file contains your own modifications to the default setup. It has a different syntax.

You want to change the files in e.g.

DCS World\Mods\aircraft\A-10C\Input\A-10C\joystick

A warrior's mission is to foster the success of others.

i9-12900K | MSI RTX 3080Ti Suprim X | 128 GB Ram 3200 MHz DDR-4 | MSI MPG Edge Z690 | Samung EVO 980 Pro SSD | Virpil Stick, Throttle and Collective | MFG Crosswind | HP Reverb G2

RAT - On the Range - Rescue Helo - Recovery Tanker - Warehouse - Airboss

Link to comment
Share on other sites

  • 1 month later...
You are looking at the .diff.lua

That file contains your own modifications to the default setup. It has a different syntax.

You want to change the files in e.g.

DCS World\Mods\aircraft\A-10C\Input\A-10C\joystick

 

I've been looking here and there is no lua file for the Warthog for any of my aircraft except for the A-10C, F-86, Ka-50 and FW-190, and I believe they're just included default Warthog profiles also. Even though I've set up profiles for my Warthog using the in game manager for every aircraft I own. I even did a search of my entire drive for "Throttle-HOTAS Warthog" and the only lua files it found were for those 4 aircraft. There is of course the .diff files in the saved games folder, but those don't do me any good obviously.

Link to comment
Share on other sites

BobFlex,

What is it that you're trying to accomplish?

hsb

HW Spec in Spoiler

---

 

i7-10700K Direct-To-Die/OC'ed to 5.1GHz, MSI Z490 MB, 32GB DDR4 3200MHz, EVGA 2080 Ti FTW3, NVMe+SSD, Win 10 x64 Pro, MFG, Warthog, TM MFDs, Komodo Huey set, Rverbe G1

 

Link to comment
Share on other sites

BobFlex,

What is it that you're trying to accomplish?

 

Basically what the OP of the thread explained, setting up a few of the warthog toggle switches to in game switches. My problem is the lua files to edit seem to just not exist on system.

Link to comment
Share on other sites

The files that you created are stored in the Saved Games\DCS folder. If you actually saved profiles, they are in there somewhere, depending on what you chose when you saved them.

 

The default files which came with the sim are under DCS\Mods\aircraft\*aircraft name*\Input\*aircraft name (or some variation of)\joystick.

 

For example, the Bf-109k sim mode file is in

 

..\DCS World\Mods\aircraft\Bf-109K-4\Input\Bf-109K-4\joystick

 

You won't find one that says Warthog in the name unless the vendor created one for that stick. Otherwise it is just the default.lua found in that location.

ASUS ROG Maximus VIII Hero, i7-6700K, Noctua NH-D14 Cooler, Crucial 32GB DDR4 2133, Samsung 950 Pro NVMe 256GB, Samsung EVO 250GB & 500GB SSD, 2TB Caviar Black, Zotac GTX 1080 AMP! Extreme 8GB, Corsair HX1000i, Phillips BDM4065UC 40" 4k monitor, VX2258 TouchScreen, TIR 5 w/ProClip, TM Warthog, VKB Gladiator Pro, Saitek X56, et. al., MFG Crosswind Pedals #1199, VolairSim Pit, Rift CV1 :thumbup:

Link to comment
Share on other sites

So what file do I need to edit then? Because if I create and save a profile for my Warthog thottle it just saves it as a .diff file and that can't be edited like the original post explains.

Link to comment
Share on other sites

BobFlex,

I'll try to explain it this weekend when I have some time. With recent updates (well, not so recent) DCS changed what and how the files need to be changed. So lot of the earlier recommendations don't work.

hsb

HW Spec in Spoiler

---

 

i7-10700K Direct-To-Die/OC'ed to 5.1GHz, MSI Z490 MB, 32GB DDR4 3200MHz, EVGA 2080 Ti FTW3, NVMe+SSD, Win 10 x64 Pro, MFG, Warthog, TM MFDs, Komodo Huey set, Rverbe G1

 

Link to comment
Share on other sites

Document How to Modify Control Binding Files

 

There is a lot of posts with questions about the subject "how to achieve 2-position or 3-position control with 1 resp. 2 switches". And a lot of people waste their time explaining the same things over and again, albeit not always at the level of detail that might be required. I have done a few modifications in the last few months and I have documented what I learned. I'm posting this document for use by anybody who might benefit.

I'll be happy to receive suggestions for improvement or additional items.

Edited 05-MAY-2017:

- added definitions on switch types

- added example for "Using a Maintained ON/OFF switch for an ON/OFF toggle (KA-50)"

- some clean-up

Edited 18-FEB-2018:

- added method and examples for KA-50 (using info from clickabledata.lua, devices.lua and command_defs.lua)

How to Edit Control Binding Files.pdf


Edited by LeCuvier
adding solution for KA-50
  • Like 3

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

Yup. And it doesn't help that ED changes how the files are used over time. And that it's not documented.

 

This link:http://forums.eagle.ru/showpost.php?p=2631827&postcount=171

explains why trying to change the DIFF.LUA doesn't work. It seems like it should work, but it doesn't. Not as of January, anyway.

 

 

This post:

http://forums.eagle.ru/showpost.php?p=2017801&postcount=52

 

helped me a great deal in trying to figure where where the numeric values are coming from.

 

Also, if you read the thread from post 171 on (it's not that many pages), you'll get a feel for what needs to be done. LeCuvier's PDF will get you started. I didn't get a chance to redo my switch box this weekend, but will try to get to it in the next few weeks. And I'll document as I go along.

hsb

HW Spec in Spoiler

---

 

i7-10700K Direct-To-Die/OC'ed to 5.1GHz, MSI Z490 MB, 32GB DDR4 3200MHz, EVGA 2080 Ti FTW3, NVMe+SSD, Win 10 x64 Pro, MFG, Warthog, TM MFDs, Komodo Huey set, Rverbe G1

 

Link to comment
Share on other sites

  • 3 weeks later...

Re: Default Document How to Modify Control Binding Files

 

There is a lot of posts with questions about the subject "how to achieve 2-position or 3-position control with 1 resp. 2 switches". And a lot of people waste their time explaining the same things over and again, albeit not always at the level of detail that might be required. I have done a few modifications in the last few months and I have documented what I learned. I'm posting this document for use by anybody who might benefit.

I'll be happy to receive suggestions for improvement or additional items.

 

I downloaded and read your pdf - excellent work.

 

I am trying to do something fairly simple for the F15, which is to make the Boatswitch on the TM Warthog throttle control the Modes. Push forward for BVR, return to center for NAV, pull back for Close Combat, return to center for NAV.

 

I was about to piss and moan that it didn't work, but as I pasted the code into this message, I saw I had missed the end comma from an edited line, fixed and now all working.

 

The key issue seems to be that you used to do this all from your

 

"C:\Users\[userName]\Saved Games\DCS\Config\Input\[aircraftName]"

 

directory, whereas now if you want to mod a control file you need to edit

 

"C:\Program Files\Eagle Dynamics\DCS World[Version]\Mods\aircraft\[aircraftName]\Input\joystick\default.lua"

 

or maybe even the Input\keyboard equivalent

 

Thanks for your excellent work.

 

Now the next issue is conditional keys: I know it can be done, because the A10C has a control that does one thing on the ground and another in the air, so will have a go at working in an "IF{..}ELSE{..}" or "SWITCH{CASE..}" or whatever the LUA equivalent into a default.lua file.

 

If anyone has had any success, please feel free to share.

Link to comment
Share on other sites

I downloaded and read your pdf - excellent work.

 

The key issue seems to be that you used to do this all from your

 

"C:\Users\[userName]\Saved Games\DCS\Config\Input\[aircraftName]"

 

directory

No, paragraph 3.1 states that the "default.lua" files are under "C:\Program Files\..."

Good luck with your project, it seems very challenging. Please share your findings with us!

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

I got down = iCommandxxx, up = iCommandyyy working pretty easily. I have encountered one problem, which is I cannot find the syntax to run two commands with one press.

 

For example, in order to get altitude hold to work in the F15, attitude hold needs to be on. So the command would be (in codelish)

 

{down = iCommandPlaneAutopilot [+, &, |, || or something] iCommandPlaneStabHbar, up = iCommandPlaneStabCancel, name = _('Autopilot - Altitude Hold'), category = _('Autopilot')},

 

Anyone any idea of the joining character, which obviously cannot be a comma, so I put in some suggestions.

 

Many thanks.

Link to comment
Share on other sites

I got down = iCommandxxx, up = iCommandyyy working pretty easily. I have encountered one problem, which is I cannot find the syntax to run two commands with one press.

 

For example, in order to get altitude hold to work in the F15, attitude hold needs to be on. So the command would be (in codelish)

 

{down = iCommandPlaneAutopilot [+, &, |, || or something] iCommandPlaneStabHbar, up = iCommandPlaneStabCancel, name = _('Autopilot - Altitude Hold'), category = _('Autopilot')},

 

Anyone any idea of the joining character, which obviously cannot be a comma, so I put in some suggestions.

 

Many thanks.

Multiple commands from on button input seems more complex by an order of magnitude. This Thread gives some insight:

start.pngED Forums » English » Sim Topics » Input and Output » Multiple keys mapped to one key or button - possible?

I found a good example in the Mirage 2000 folder. RAZBAM has implemented the entire autostart sequence that way. Look for "Macro_sequencies.lua" in the folder "C:\Program Files\Eagle Dynamics\DCS World\Mods\aircraft\M-2000C\Cockpit". But read through the above thread first. You will see that you have to understand the files "clickabledata.lua", "command_defs.lua", "devices.lua", device_init.lua" etc.

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

I think you are correct - with multiple commands and/or conditional commands I am running a macro and will need a lua script. Unfortunately, I don't own the Mirage, so cannot look at that code.

 

I can tell you that neither of these work:

{down = iCommandxxx, down = iCommandyyy, up = iCommandzzz, name = ....}

 

{down = (iCommandxxx, iCommandyyy), up = iCommandzzz, name = ....}

 

However if anyone is interested in the F15 autopilot and the Warthog, here was the solution with no sexy code, just thinking. Up to path to activate attitude, two down to alt to activate autopilot, one back to center for autopilot off. Seems to work fine. Code below:

 

{down = iCommandPlaneAutopilot, name = _('Autopilot - Attitude Hold'), category = _('Autopilot')}, --BIND THIS TO PATH POSITION

{down = iCommandPlaneStabHbar, up = iCommandPlaneStabCancel, name = _('Autopilot - Altitude Hold'), category = _('Autopilot')}, --BIND THIS TO ALT POSITION

Link to comment
Share on other sites

I think you are correct - with multiple commands and/or conditional commands I am running a macro and will need a lua script. Unfortunately, I don't own the Mirage, so cannot look at that code.

 

I can tell you that neither of these work:

{down = iCommandxxx, down = iCommandyyy, up = iCommandzzz, name = ....}

 

{down = (iCommandxxx, iCommandyyy), up = iCommandzzz, name = ....}

 

However if anyone is interested in the F15 autopilot and the Warthog, here was the solution with no sexy code, just thinking. Up to path to activate attitude, two down to alt to activate autopilot, one back to center for autopilot off. Seems to work fine. Code below:

 

{down = iCommandPlaneAutopilot, name = _('Autopilot - Attitude Hold'), category = _('Autopilot')}, --BIND THIS TO PATH POSITION

{down = iCommandPlaneStabHbar, up = iCommandPlaneStabCancel, name = _('Autopilot - Altitude Hold'), category = _('Autopilot')}, --BIND THIS TO ALT POSITION

Hi Durham, I was tempted to try something for the F-15, but I found that the structure for Flaming Cliffs aircraft is totally different. The folder structure and files described by Teej in his posts don't exist, and even if I added them I think it wouldn't do any good. I suspect that Flaming Cliffs doesn't work like the other Mods and therefore can't be customized the same way.

LeCuvier

Windows 10 Pro 64Bit | i7-4790 CPU |16 GB RAM|SSD System Disk|SSD Gaming Disk| MSI GTX-1080 Gaming 8 GB| Acer XB270HU | TM Warthog HOTAS | VKB Gladiator Pro | MongoosT-50 | MFG Crosswind Pedals | TrackIR 5

Link to comment
Share on other sites

I used to use the in game config files to set up all my TM warthog switches. But honestly I've found Autohotkey to be a far superior and more flexible solution which I highly recommend to anyone in this situation.

 

It's simple, it's universal, you never have to worry about updates overwriting changes to the lua files, or ED changing the way they work.

 

You just leave all of the game commands as their default keyboard commands, and use autohotkey to make a script file for each DCS module binding the keys you want to the switches you want.

 

I find it works better in general too. I was following some lua editing examples for the mig21 from the leatherneck forum, and I found that the commands would eventually time out and not work. For example the WH switch left in the up position for a long time, I would flip it down and it wouldn't respond, as if it had timed out. This is never an issue with Autohotkey. It's fast, responsive, and reliable.

 

Yes, it can be a nuisance to start a script before flying each module. But I automated that process too and built it into the profile switching in Voice Attack. At worst you have a bunch of scripts on your desktop and you have to alt tab and start a different one if you want to go fly another plane.

 

Take my advice and look into it, you'll never want to go back to fiddling with the DCS configs.


Edited by FeistyLemur
Link to comment
Share on other sites

Interesting. I'll have to look into this. Now, because you can't modify the diff.lua file, you have to remember to restore the default.lua before upgrades, then put the changes back in after the upgrade. JGSME or not, it's easy to forget. I'll have to look into autohotkey. Thanks

hsb

HW Spec in Spoiler

---

 

i7-10700K Direct-To-Die/OC'ed to 5.1GHz, MSI Z490 MB, 32GB DDR4 3200MHz, EVGA 2080 Ti FTW3, NVMe+SSD, Win 10 x64 Pro, MFG, Warthog, TM MFDs, Komodo Huey set, Rverbe G1

 

Link to comment
Share on other sites

The way I ended up getting turned on to it was with Vaicom which required it at the time. I liked it so much I started using it for everything.

 

Here's an example of how you set up a 3 way WH swtich (which is basically treated exactly the same as 2 ways but with a shared position for off when it detects the button being released.)

 

 

; --- HOTAS WH Throttle Buttion 13

3Joy13::

Send g

SetTimer, WaitForButtonUp13, 10

return

 

WaitForButtonUp13:

if GetKeyState("3Joy13")

return

Send ^g

SetTimer, WaitForButtonUp13, off

return

 

; --- HOTAS WH Throttle Buttion 14

3Joy14::

Send +g

SetTimer, WaitForButtonUp14, 10

return

 

WaitForButtonUp14:

if GetKeyState("3Joy14")

return

Send ^g

SetTimer, WaitForButtonUp14, off

return

 

 

What that does for example is when i use the pinky switch up (button 13) it sends g, then waits for it to release. When it releases it sends ctrl g. Likewise button 14 (pinky switch down) it fires alt g and waits. Then when it detects release it fires ctrl g. This effectively binds the 3 position gear selector of the mig21 to the pinky switch on the throttle.

 

Basically an auto hotkey script is a simple plaintext script file you can put on your desktop (eg Mig21.ahk). When you want to run it you double click, and that's it, it's running, and a little icon appears in the system tray. To stop it you right click and hit stop.

 

The only negative traits are. 1: you have to remember to start it. 2: you should really remember to put all your switches in the off position before triggering a script, or else it spams a bunch of keypresses at once which can be annoying, and 3: there is a learning curve. 4: as always single press functions can become "out of sync" toggle keys such as press G for gear up press G for gear down again. But it's well worth it, and you can do very simple things like what I've done here up to extremely complex and powerful things. Very useful tool. I find it much simpler and convenient to use than something like TARGET. And TARGET I found was laggy and just a bitch to use. This is fast and very responsive.

 

Once you have one file set up for all the keys on your warthog it becomes super trivial to make a script for a new module too. Because all you have to do is duplicate a script for your next module, and change the "send" lines appropriately for what you want it to do, comment out any buttons you may not want to rebind, rename it, and you're done. Unless they change the default bindings for the module, which seldom happens, you're permanently set for that module and never have to piss around with LUA again. At worst you might have to do a simple edit if for some reason they changed a base keybind.


Edited by FeistyLemur
Link to comment
Share on other sites

Ah. The going out of sync may be a deal breaker. But it certainly seems like a capable program. Thanks for the detailed follow up. It'll help me get started and see which I prefer.

hsb

HW Spec in Spoiler

---

 

i7-10700K Direct-To-Die/OC'ed to 5.1GHz, MSI Z490 MB, 32GB DDR4 3200MHz, EVGA 2080 Ti FTW3, NVMe+SSD, Win 10 x64 Pro, MFG, Warthog, TM MFDs, Komodo Huey set, Rverbe G1

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...