Jump to content

How to set up toggle switches (a tutorial)


Recommended Posts

I'l ask again before you go off. What switch are you trying to toggle.. like, visually. Your post mentions Armament, yet your code reflects countermeasure.

 

Because if it's the Armament-safety your after, throw away all of your shit from the last 10 posts and just try this:

 

{down = device_commands.Button_8, up = device_commands.Button_8, cockpit_device_id = devices.WEAPON_SYS, value_down = 1.0, value_up = -1.0, name = _('Armament OFF/ARMED'), category = _('Armament System')}

 

Reasoning is simple, Belsim likes using (and we like having them) up/down toggles for switches with multiple positions. So where as most people just assume -1 (or 0) is off, and 1 == on. This actually triggers a "increase positions by one, and decrease by one" under the hood. So you just have to check under the hood... what binds are there, so in clickabledata, not in controls. The ones in controls use the "easy" helper functions. Something you don't want if you want to simulate the full switch. E.g. to get to the line I posted above, my steps where this:

 

afdf6e4a082663c84412040fe7d63f63.jpg


Edited by CrashO
everything is better with pictures...
  • Like 1
Link to comment
Share on other sites

I Do have the Huey, and got some questions about the desired result because i'm lost. Do you want to toggle the Armament-switch (master-arm) , e.g. Brrrrrrrrrrt, switch. Or the one that enables/disables your countermeasures?

 

XM_130 device == Countermeasures box. I'm kind of surprised it actually does something.

 

I chose an arbitrary toggle switch to experiment on as there are a bunch of toggles i want to bind to my button board- which has several 'Maintained ON/OFF' switches. It happened to be the "SAFE/ARMED Switcher" which you correctly point out, is in fact the Countermeasures ARM switch. (sorry for the confusion)

 

Perhaps thats the issue- I will test on another Toggle- Tomorrow! Cheers

Occulus Rift i7-7700 3.6Ghz 16GB Ram 1080Ti 11GB SSDx2

Link to comment
Share on other sites

Perhaps thats the issue- I will test on another Toggle- Tomorrow! Cheers

I have the SAFE/ARM switch of the countermeasures mapped in my configuration. So it should work in general. Will check this evening (GMT) when I get home.

 

But as CrashO pointed out, the clickabledata.lua is also something you should have a look at. And as LeCuvier said, not all buttons are configurable in the same way. Sometimes there are differences which are under the hood, i.e. in the code only the developers have access to. However, most of the time I can configure the buttons to my linking.

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

OK- so i stayed up mucking around with this much longer than i expected...

 

I managed to get some Toggles to bind as I wanted (woohoo). eg Landing Light ON/OFF and Rear Doors Open/Close.

 

I used Funkyfrankys code eg.

{down = device_commands.Button_12, up = device_commands.Button_12, cockpit_device_id = devices.NAVLIGHT_SYSTEM, value_down = 0.0, value_up = 1.0, name = _('Landing Light ON/OFF Switch'), category = _('Ins Collective Stick')},

 

instead of the default:

{down = device_commands.Button_12, cockpit_device_id = devices.NAVLIGHT_SYSTEM, value_down = 1.0, name = _('Landing Light Switch'), category = _('Ins Collective Stick')},

 

CrashO....Despite your EXCELLENT pictorial explanation, Im still trying to understand whats up with my setup. I simply can not find any Button 8 for the Armament system in my default.lua- despite it being coded exactly as yours in the clickable.lua??? Mine is Button 20 eg

{down = device_commands.Button_20, cockpit_device_id = devices.WEAPON_SYS, value_down = 1.0, name = _('Armament Off/Safe/Armed Up'), category = _('Armament System')},

{down = device_commands.Button_20, cockpit_device_id = devices.WEAPON_SYS, value_down = -1.0, name = _('Armament Off/Safe/Armed Down'), category = _('Armament System')},

 

I cut and paste your supplied code straight into my default.lua but no joy. I tried changing the button to 20- no luck either.

 

Ill be back tomorrow with more Questions. Thanks for the help guys.. keep it coming

Occulus Rift i7-7700 3.6Ghz 16GB Ram 1080Ti 11GB SSDx2

Link to comment
Share on other sites

I know you can't find a button 8 in your default.lua. That's the whole point (the preset binds use the virtualbutton (more accurately, a macro) "button 20" that toggles between 3 states. Off/Safe/Armed.

 

099487e687dd6e4854f7228044264d65.png

I drew a diagram for you.

The Top one shows what button 20 (the one implemented in default.lua) does in this case. You can see that whenever you hit the button, it just shifts to the next (or previous state). Great to do a lot of states with only 2 buttons. Not great if you want it to correspond with a physical button. As there is no way to have one keypress, always pointing to the same state.

 

The bottom one ( button 8 ) is the one you need for what you want. Take for example the value of -1.00. (in RED), you can see that whatever the old state is, whether it's off, safe or armed. It will always turn OFF if you enter that value. The same for 0 (safe) and 1 (armed).

 

That's what I tried to explain. If a key-bind has 3 keys in the description (this one was labeled "Armament Off/Safe/Armed Up"), for 1 single button. You can tell there is some black-magic going to be happening under the hood. In this case, some toggle-state magic in the form of a macro, called button_20. Which is why I opened up clickabledata and found that "button 8" is the real-actual-button it uses.

 

TL;DR:

Button 20 = No real button, totally fake, fake news...button. It's a virtual copy of button 8 that takes the last state and toggles to the next or previous state. Great for using 1 click to turn a knob 1 click, or move a switch 1 click. Not so great to bind to toggle switches.

Button 8 = The Armament switch.

 

And copy pasting my line in, should Work. I tested my code, and it runs just fine. Don't forget a comma at the end of the line to separate if from other key-commands though, But I kind of assumed that was obvious.

 

The reason why what you tried does work for Funkyfrankys's code when binding a landing light. Is because those are 2-position switches. And this ARM one has more then 2 (and uses that state thing). So just keep an eye on the description. A single button with more then 2 functions (on/off) == something special going on. For everything else your old method should work fine.


Edited by CrashO
state-magic-picture-porn update
Link to comment
Share on other sites

And copy pasting my line in, should Work. I tested my code, and it runs just fine. Don't forget a comma at the end of the line to separate if from other key-commands though, But I kind of assumed that was obvious.

.

 

Ahhhh... that missing comma! Thats all it was! If it had been a missing washer, bolt, spring or pin, Id have spotted it right away- I guess im a mechanical guy...

 

Got it working now... although i need to tweak it so it goes from OFF to ARM rather than OFF to SAFE. (I dont need the safe position) Thanks again.

Occulus Rift i7-7700 3.6Ghz 16GB Ram 1080Ti 11GB SSDx2

Link to comment
Share on other sites

although i need to tweak it so it goes from OFF to ARM rather than OFF to SAFE. (I dont need the safe position) Thanks again.

What tweak? I figured you only wanted OFF/ARM, so thats what I wrote it for... it does nothing with safe. I included it in the state-pic-torial for completeness. But the line has only off (-1.00) and arm (1.00). Safe would be 0.00 as a value.

 

This is what happens in-game when I stick my line in and toggle the switch on my warthog up and down.

1203f73cabbc1370aadb562fa10bed01.gif

 

This sounds more like you took Funkyfrankys code instead of mine and just replaced the buttons, and device ID. Leaving the wrong values.


Edited by CrashO
Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

 

Hope someone can help me, I have lots to do with my VR simpit, and need to sort out my switch bindings. I fly around in the MiG29 in VR. Reaching for the keyboard is a pain. My flight stick has few buttons, so I bought some On-Off toggles and wired them to a USB Joystick controller board. As expected the toggle switch replicates a keypress down, so I have to switch on+off for on, then on+off for off, which is not good. I need to have the on off replicated.

 

How do I get from this...

local diff = {

["keyDiffs"] = {

["d175pnilunilcdnilvdnilvpnilvunil"] = {

["added"] = {

[1] = {

["key"] = "JOY_BTN4",

},

},

["name"] = "Navigation lights",

},

},

}

return diff

 

...to what you guys have mentioned as on off?

 

Thanks in anticipation.

 

Further to this I find this...

local res = external_profile("Config/Input/Aircrafts/base_joystick_binding.lua")

So I got there and find this....

local res = external_profile("Config/Input/Aircrafts/base_keyboard_binding.lua")

and in that file I find this....

{combos = {{key = 'L', reformers = {'RCtrl'}}}, down = iCommandPlaneLightsOnOff, name = _('Navigation lights'), category = _('Systems')},

 

So I go to this...

{down = iCommandPlaneLightsOnOff, name = _('Navigation lights'), category = _('Systems')}, and add it to the default for the Mig29C ?

 

Now I am stuck... I tried this but it does not work as intended....

{down = iCommandPlaneLightsOnOff, up = iCommandPlaneLightsOnOff, value_down = 0.0, value_up = 1.0, name = _('Navigation lights On/Off'), category = _('SimPit')},


Edited by DoctorStrop

Windows 10 64bit, Intel i7 6700K, 32GB Corsair 2400Mhz, 970 NVMe 500Gb SSD, GeForce 2080 super, HP Reverb, VKB GF PRO, Thrustmaster Warthog throttle, Thrustmaster Pendular rudders, Windows + DCS :thumbup:

 

My youtube channel

Link to comment
Share on other sites

@DoctorStrop:

I have managed to add the desired command "Navigation Lights 2-Pos ON/OFF to the MIG-29S, by

1. adding the following code line into the file "C:\Program Files\Eagle Dynamics\DCS World\Mods\aircraft\Flaming Cliffs\Input\mig-29c\joystick"

{down = iCommandPlaneLightsOnOff, up = iCommandPlaneLightsOnOff, name = _('Navigation Lights 2-Position ON/OFF'), category = _('Systems')},

2. Binding this new command to a maintained ON/OFF switch on my throttle.

 

This method should work for other commands as well. If you have a list of ON/OFF commands you wish to add we can work on it.

 

PS: You may want to download the tutorial under post #214 in order to get an understanding of what I'm doing there.


Edited by LeCuvier
  • Like 1

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

@DoctorStrop:

I have managed to add the desired command "Navigation Lights 2-Pos ON/OFF to the MIG-29S, by

1. adding the following code line into the file "C:\Program Files\Eagle Dynamics\DCS World\Mods\aircraft\Flaming Cliffs\Input\mig-29c\joystick"

{down = iCommandPlaneLightsOnOff, up = iCommandPlaneLightsOnOff, name = _('Navigation Lights 2-Position ON/OFF'), category = _('Systems')},

2. Binding this new command to a maintained ON/OFF switch on my throttle.

 

This method should work for other commands as well. If you have a list of ON/OFF commands you wish to add we can work on it.

 

PS: You may want to download the tutorial under post #214 in order to get an understanding of what I'm doing there.

 

Hey thanks for your contribution. I noticed you do not have the "value" properties that I have, so I have taken them out and it works.

 

Is there anyway I can add these commands to separate file and call it from the default.lua in the path you mentioned.

Windows 10 64bit, Intel i7 6700K, 32GB Corsair 2400Mhz, 970 NVMe 500Gb SSD, GeForce 2080 super, HP Reverb, VKB GF PRO, Thrustmaster Warthog throttle, Thrustmaster Pendular rudders, Windows + DCS :thumbup:

 

My youtube channel

Link to comment
Share on other sites

@DoctorStrop:

These commands like "iCommandPlaneLightsOnOff" don't use "value" attributes.

And from what I know the commands have to be in the "default.lua".

Modules outside "Flaming Cliffs" often have equivalent files for specific HOTAS controls, and if they do then these respective files are to be used for the related control device. But you cannot use other files for these commands because the software won't look into them.

Note: The command I created is a modification of the original command. The original command does not have the "up = iCommandPlaneLightsOnOff" statement and therefore acts as a pushbutton command. By adding the statement I changed it to a maintained ON/OFF command. There are some ON only and OFF only commands that require one pushbutton each. They can be combined into maintained 2-position commands for a single ON/OFF switch.

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

@DoctorStrop:

These commands like "iCommandPlaneLightsOnOff" don't use "value" attributes.

And from what I know the commands have to be in the "default.lua".

Modules outside "Flaming Cliffs" often have equivalent files for specific HOTAS controls, and if they do then these respective files are to be used for the related control device. But you cannot use other files for these commands because the software won't look into them.

Note: The command I created is a modification of the original command. The original command does not have the "up = iCommandPlaneLightsOnOff" statement and therefore acts as a pushbutton command. By adding the statement I changed it to a maintained ON/OFF command. There are some ON only and OFF only commands that require one pushbutton each. They can be combined into maintained 2-position commands for a single ON/OFF switch.

 

I added them to this file...

D:\Eagle Dynamics\DCS World\Config\Input\Aircrafts\base_joystick_binding.lua

..now they can be seen by all my FC3 aircraft.

Windows 10 64bit, Intel i7 6700K, 32GB Corsair 2400Mhz, 970 NVMe 500Gb SSD, GeForce 2080 super, HP Reverb, VKB GF PRO, Thrustmaster Warthog throttle, Thrustmaster Pendular rudders, Windows + DCS :thumbup:

 

My youtube channel

Link to comment
Share on other sites

I added them to this file...

D:\Eagle Dynamics\DCS World\Config\Input\Aircrafts\base_joystick_binding.lua

..now they can be seen by all my FC3 aircraft.

Yes, that's the mother of all FC3 HOTAS commands

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

Any ideas how this can be bound, and to what type of switch? I am guessing this command cycles the through the "near" "far" and "off" states, so am guessing it can only be a button with momentary action.

 

{down = iCommandPlaneHeadLightOnOff, name = _('Gear Light Near/Far/Off'), category = _('SimPit')},

Windows 10 64bit, Intel i7 6700K, 32GB Corsair 2400Mhz, 970 NVMe 500Gb SSD, GeForce 2080 super, HP Reverb, VKB GF PRO, Thrustmaster Warthog throttle, Thrustmaster Pendular rudders, Windows + DCS :thumbup:

 

My youtube channel

Link to comment
Share on other sites

Any ideas how this can be bound, and to what type of switch? I am guessing this command cycles the through the "near" "far" and "off" states, so am guessing it can only be a button with momentary action.

 

{down = iCommandPlaneHeadLightOnOff, name = _('Gear Light Near/Far/Off'), category = _('SimPit')},

Right, this needs to be a switch type that returns to the OFF position when you release it.

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

  • 5 weeks later...

Hallo! Sag mir, was wird der SU25-Code für Klappen von Warthog aussehen? Vielen Dank im Voraus!


Edited by oltim

Система 10 про. Железяки: Мать Z690M, ccd m2 500gb,  i5 12600, 3090 24gb., DDR4 64gb (2667), монитор LG C1 4K 120Hz 55, Opentrack.

Link to comment
Share on other sites

Hallo! Sag mir, was wird der SU25-Code für Klappen von Warthog aussehen? Vielen Dank im Voraus!

German is my mother tongue, but I'm not sure what the question is. Also, this is an English forum. If you prefer to use German, you shoulöd post in the German forum.

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

German is my mother tongue, but I'm not sure what the question is. Also, this is an English forum. If you prefer to use German, you shoulöd post in the German forum.
He did and it is already solved, IIRC.

Shagrat

 

- Flying Sims since 1984 -:pilotfly:

Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B  | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore)

Link to comment
Share on other sites

This type of functionality should have been integrated into the core game, it makes the warthog HOTAS useless for other planes
Hmm, what about specialities from other HOTAS, like the Thumbstick on Saitek?

There are about hundreds of game controllers and joysticks out there.

It would have been nice, if Thrustmaster had done the Warthog with 3 Buttons for 3-Way switches, and 2 Buttons for 2-Way switches, rather than requiring a "game" to evaluate "on/off" states...

 

Thrustmaster would argue to use T.A.R.G.E.T to configure it, but I would rather have a button for each state of the switch.

Shagrat

 

- Flying Sims since 1984 -:pilotfly:

Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B  | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore)

Link to comment
Share on other sites

Hi all, I'm trying to make my On-Off-On switches switch off in the centre position using a leo bodnar board. I was going to use the first post but when I go into the Input folder my button binding is such

 

["dnilp3025unilcd3vdnilvp-1vunil"] = {

["added"] = {

[1] = {

["key"] = "JOY_BTN7",

},

},

["name"] = "Throttle Down",

},

["dnilp3025unilcd3vdnilvp1vunil"] = {

["added"] = {

[1] = {

["key"] = "JOY_BTN6",

},

},

["name"] = "Throttle Up",

},

 

How do I change this to reflect what I want to do?

 

Thanks


Edited by mr_mojo97

MSI M5 z270 | Intel i5 7600k (OC) 4.8GHz | MSI GTX1080ti Gaming X 11Gb | 500gb Samsung 970 Evo NVME M.2 (DCS World) | 500gb Samsung 850 Evo SSD (OS and Apps) | 32Gb 2400MHz DDR4 - Crucial Ballistix | Be Quiet Silent Loop 240mm | NZXT H440 case |

 

Thrustmaster Warthog - 47608 with Virpil Mongoose joystick base | MFG Crosswinds - 1241 | Westland Lynx collective with Bodnar X board | Pilot's seat from ZH832 Merlin | JetSeat | Oculus Rift S | Windows 10 | VA |

Link to comment
Share on other sites

Hi all, I'm trying to make my On-Off-On switches switch off in the centre position using a leo bodnar board. I was going to use the first post but when I go into the Input folder my button binding is such

 

["dnilp3025unilcd3vdnilvp-1vunil"] = {

["added"] = {

[1] = {

["key"] = "JOY_BTN7",

},

},

["name"] = "Throttle Down",

},

["dnilp3025unilcd3vdnilvp1vunil"] = {

["added"] = {

[1] = {

["key"] = "JOY_BTN6",

},

},

["name"] = "Throttle Up",

},

 

How do I change this to reflect what I want to do?

 

Thanks

What do you want to switch OFF in the Center position, and for which aircraft?

If you use the switch for the throttle, it doesn't make sense to switch something OFF when you stop increasing or decreasing the throttle.

And the place for customizing is not the .diff.lua file under Saved Games, but the "default.lua" or equivalent under "C:\Program Files\Eagle Dynamics\DCS World\Mods\aircraft\Bf-109K-4\Input\Bf-109K-4\joystick" (Bf-109K-4 being a placeholder for the aircraft you want to mofify).

Post #214 has a tutorial document explaining how to to these modifications.

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

Ah, I didn't realise it was the diff.lua file! Anyways, I'm using a collective from a Westland Lynx (which has no throttle as it's FADEC) so I'm using of it's on-off-on switches as th throttle. Although now I'm thinking of using the momentary switch beside it which may be better.

 

Ok I'll look into that post later.

 

Cheers LeC


Edited by mr_mojo97

MSI M5 z270 | Intel i5 7600k (OC) 4.8GHz | MSI GTX1080ti Gaming X 11Gb | 500gb Samsung 970 Evo NVME M.2 (DCS World) | 500gb Samsung 850 Evo SSD (OS and Apps) | 32Gb 2400MHz DDR4 - Crucial Ballistix | Be Quiet Silent Loop 240mm | NZXT H440 case |

 

Thrustmaster Warthog - 47608 with Virpil Mongoose joystick base | MFG Crosswinds - 1241 | Westland Lynx collective with Bodnar X board | Pilot's seat from ZH832 Merlin | JetSeat | Oculus Rift S | Windows 10 | VA |

Link to comment
Share on other sites

Ah, I didn't realise it was the diff.lua file! Anyways, I'm using a collective from a Westland Lynx (which has no throttle as it's FADEC) so I'm using of it's on-off-on switches as th throttle. Although now I'm thinking of using the momentary switch beside it which may be better.

 

Ok I'll look into that post later.

 

Cheers LeC

 

You can get it to work, but you have to modify the lua files. Take a look at these two posts:

 

https://forums.eagle.ru/showpost.php?p=2893725&postcount=104

https://forums.eagle.ru/showpost.php?p=2894628&postcount=106

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

Hello! I want to create a brake release code for su 33 code created by analogy with the release of the chassis.

Here is the Gear release code:

{down = iCommandPlaneGearUp, up = iCommandPlaneGearDown, name = 'Alternate Landing Gear Toggle', category = 'Systems'},

 

here is the my toric code of the release Arrestor Hook

{down = iCommandPlaneHookUp, up = iCommandPlanelaneHookDown, name = 'Alternate Arrestor Hook Toggle', category = 'Systems'},

 

in the game the code appears, but does not work in what error?

sorry for Google translate


Edited by oltim

Система 10 про. Железяки: Мать Z690M, ccd m2 500gb,  i5 12600, 3090 24gb., DDR4 64gb (2667), монитор LG C1 4K 120Hz 55, Opentrack.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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