Jump to content

How to set up toggle switches (a tutorial)


Recommended Posts

The code in the tutorial is what I have in my "default.lua", and it works as I just verified. The code in your post is different from what the tutorial shows.

I repeat the correct code from the tutorial:

 

I edited my own lines in the file rather than copying and pasting from the .pdf. I shouldn't have done that and simply copied straight from your document.

 

Nonetheless, I still cannot get it to work.

 

I am assuming that in the control commands (in-game), it's just the two flap positions out of the 3 possibles leaving empty also the two basic control commands; [i][b]flap up and flap down[/b][/i]. So only binding the [i][b]flap 0[/b][/i] and [b][i]flap 45[/i][/b] of the flap control commands - leaving [b][i]flap 25[/i][/b] empty?

Link to comment
Share on other sites

@Red Earth: I'm wondering whether the problem might be of a different nature. Where in the file did you put the code? Maybe you should post your "default.lua" so we can look at it.

I just realize that your second line of code has a double-comma in it:

{down=device_commands.Flaps45,cockpit_device_id=devices.FLAPS,,up=device_commands.Flaps25,cockpit_device_id=devices.FLAPS,value_down=1.0,value_up=1.0,name=_('Flaps_3_Pos_Down'),category=_('Flight   Controls')},

between these two fields: cockpit_device_id=devices.FLAPS,,up=device_commands.Flaps25

That's invalid code.


Edited by LeCuvier

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

@Red Earth: I removed the extra comma in your second line (see my previous post) and tried your two lines on my computer. The code works, although it's a bit "unorthodox":

1. the cockpit_device_id is only necessary once, you have it twice

2. you have the cockpit_device_id between "up" and "down". It's good practice to have "up", "down" (if required) and then cockpit_device_id

 

 

Remove the extra comma and try again; it should work. If it doesn't then make sure the lines are in the right part of the file as described in the tutorial.

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

No tested again - no work. I actually started again with a virgin copy of the default.lua from the main DCS folder, so there's something else going on.

 

In my control commands in game, there are two new entries:

 

ARU Manual/Auto - on.

ARU Manual/Auto - off.

 

These must have been created by my error in the prior default.lua file. I suspect these could be causing the error. Which file do I need to scratch and replace with a virgin file from main DCS folder - name.lua perhaps?

 

Secondly, which are the commands in control commands in-game that need to be bound:

 

a. flaps 0 - button xx

b. flaps 25 - button xx

c. flaps 45 - button xx

d. flaps on - button xx

e. flaps off - button xx

 

Currently I have my two flap commands on the T warthog throttle bound to a. and c. Is that correct?

 

Or should there be some new commands created like ARU auto/manual to bind to?

 

Thanks

Link to comment
Share on other sites

You are losing me here. If you have re-started from a virgin "default.lua" and added the two lines of code, you cannot have created ARU-related commands.

The original file has 3 ARU-related commands, but none have names as you quote.

 

Post your file and I will look at it, and add the 2 flaps command lines.

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

attached new mig21 default.lua

 

I've tried starting again with fresh button set up but the created ARU commands still exist in control/commands (in-game).

 

It seems I cannot even get a fresh blank start by deleting my input files.

 

There must be another input file I need to refresh to absolutely start from fresh.

default.lua


Edited by Red Earth
Link to comment
Share on other sites

attached new mig21 default.lua

 

I've tried starting again with fresh button set up but the created ARU commands still exist in control/commands (in-game).

 

It seems I cannot even get a fresh blank start by deleting my input files.

 

There must be another input file I need to refresh to absolutely start from fresh.

Have Mig21B in trial, just looked

default keys bindings give 4x ARU, of which 2x ARU orange

it's just there, it's DCS (error)

| VR goggles | Autopilot panel | Headtracker | TM HOTAS | G920 HOTAS | MS FFB 2 | Throttle Quadrants | 8600K | GTX 1080 | 64GB RAM| Win 10 x64 | Voicerecognition | 50" UHD TV monitor | 40" 1080p TV monitor | 2x 24" 1080p side monitors | 24" 1080p touchscreen |

Link to comment
Share on other sites

Have Mig21B in trial, just looked

default keys bindings give 4x ARU, of which 2x ARU orange

it's just there, it's DCS (error)

 

Thanks really appreciated, this answers the preliminary issue. Now I can just set up the commands from fresh.

Link to comment
Share on other sites

Flaps 3-position switch for Mig-21bis

 

I attach your "default.lua" with the flaps control bindings added in rows 21 and 22.

With respect to the ARU-related bindings, there are really only 3. The 2 orange rows in the screen (ARU - Auto/Manual) are they same command. One row is for keyboard only and the other for game controllers. The row for game controllers has a value_down value different from that for the keyboard, but both have the same name. That's why they appear in different rows and are displayed in orange. The binding for game controllers doesn't work because its value_down is wrong. I'll report the bug.

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

oops!

 

The file goes to the folder "...\DCS World OpenBeta\Mods\aircraft\MIG-21bis\Input\MiG-21\joystick" since you want to use switches on a game controller.

default.lua

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

My folder placement was correct anyhow, but def worth checking to eliminate all possibilities. But yes we have success, it now works..phew!

 

Odd thing is that I see there are two new commands created in controls in-game which I bind my flaps to. I didn't have these new commands in my own attempts to get it working, so it's still not clear to me what the explanation is for the appearance of these commands.

 

Still, all is good, immense thanks to both of you for your help!

 

I'm going to set up some other buttons for MiG 21 now such as L Gear as a single button (up/down) as is possible as standard with most other modules. I'll let you know how I get on with that. Also have the MiG 19 flaps and L Gear to do, so will let you know how it goes. :thumbup:

Link to comment
Share on other sites

  • 3 weeks later...

Hi all, have switched from DCS-BIOS to button boxes so still in the learning curve of adjusting the default.lua to get the desired results for switches and buttons. I’ve thus far had success from reading this forum and the tutorial in getting some of my ON/OFF switches to work properly (so far Master arm, L/R Generators, and a few others including some ON/OFF/ON switches. But I’ve hit a roadblock with the Pitot Heat switch. Looking at the Default.lua it only had one line of code associated with it.

 

 {down = elec_commands.PitotHeater, up = elec_commands.PitotHeater, cockpit_device_id = devices.ELEC_INTERFACE, value_down = 1.0, value_up = 0.0, name = _(‘Pitot Heater Switch - ON/AUTO’), category = {_(‘Right Console’), _(‘Electrical Power Panel’)}},    

 

My problem is it already appears to be setup to work properly but it acts as a toggle switch, so I’m having to flip the switch twice every time. Any ideas on how to solve this?

 

Thanks in advance!

TM Warthog, Oculus Rift, Win10...

Link to comment
Share on other sites

@Sickdog: You could have saved me a few minutes by indicating that this is for the Hornet! This switch is a glaring example of weird programming. It's a maintained 2-position switch in the cockpit, but the binding is for a pushbutton...Aaaaaaargh! So this is a bad starting point. The best I could do is this:

{down = elec_commands.PitotHeater, up = elec_commands.PitotHeater, cockpit_device_id = devices.ELEC_INTERFACE, value_down =  1.0, value_up = 1.0, name = _('Pitot Heater Switch - 2-Pos ON/AUTO'), category = {_('Right Console'), _('ECS Panel')}},

This code works, but the switch must be in the OFF position at mission start; else it will work in reverse. If that happens you can re-sync it by clicking on the cockpit switch once.

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

@Sickdog: You could have saved me a few minutes by indicating that this is for the Hornet! This switch is a glaring example of weird programming. It's a maintained 2-position switch in the cockpit, but the binding is for a pushbutton...Aaaaaaargh! So this is a bad starting point. The best I could do is this:
{down = elec_commands.PitotHeater, up = elec_commands.PitotHeater, cockpit_device_id = devices.ELEC_INTERFACE, value_down =  1.0, value_up = 1.0, name = _('Pitot Heater Switch - 2-Pos ON/AUTO'), category = {_('Right Console'), _('ECS Panel')}},

This code works, but the switch must be in the OFF position at mission start; else it will work in reverse. If that happens you can re-sync it by clicking on the cockpit switch once.

 

First off, Thank You LeCuvier! Secondly, sorry I forgot to mention it’s for the Hornet!! Oops. But I appreciate the quick response. I’ll give this code a try, I’m fine with that limitation. Merci!!

TM Warthog, Oculus Rift, Win10...

Link to comment
Share on other sites

Is it possible to have a "modifier" button be considered a normal button when another modifier is pressed?

 

 

For instance, I have almost all the buttons on my throttle as modifiers for the coolie had on my flight stick.

 

 

 

I want to set up a button on my flight stick as a modifier, then when it is pressed have it modify one of the buttons on my throttle.

 

 

The issue is when I put my flight stick button in as a modifier, I try to put the button on my throttle as the button that should be modified by it but that button itself is a modifier so it won't let my flight stick button press modify it.

 

 

Sorry, it's a bit confusing but I hope you get the point.

Link to comment
Share on other sites

sounds unlikely

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

Hi all...

Having built a button box (zero delay USB encoder) for the FA-18C, I have been configuring it with the newly acquired A-10C.

 

 

I see from the config bindings that the Anti-Skid is a toggle switch with a single entry in the joystick default.lua file.

 

Does anyone know of a way to split it into 2 buttons so an ON and an OFF can be bound, rather than just 1 toggle point?

 

(Similar to this post for the AV-8B? )

 

Thanks...

Phil

Link to comment
Share on other sites

Hi all...

Having built a button box (zero delay USB encoder) for the FA-18C, I have been configuring it with the newly acquired A-10C.

 

 

I see from the config bindings that the Anti-Skid is a toggle switch with a single entry in the joystick default.lua file.

 

Does anyone know of a way to split it into 2 buttons so an ON and an OFF can be bound, rather than just 1 toggle point?

 

(Similar to this post for the AV-8B? )

 

Thanks...

Phil

Add these 2 lines to your "default.lua" (or "Throttle - HOTAS Warthog.lua"):

{down = 3029, pressed = 3029, cockpit_device_id = 38, value_down = 1.0, value_pressed = 0.0, name = _('Anti-Skid Button ON'), category = _('Landing gear panel')},
{down = 3028, pressed = 3028, cockpit_device_id = 38, value_down = 1.0, value_pressed = 0.0, name = _('Anti-Skid Button OFF'), category = _('Landing gear panel')},

This is one of the weirdest mod I've ever done.

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

  • 3 weeks later...

2-Position Switch

 

Something has changed in the F/A-18C joy default.lua. Both the joystick and the keyboard file have the same line to control the Pitot heater switch on the right console:

 

 

 

{down = elec_commands.PitotHeater, up = elec_commands.PitotHeater, cockpit_device_id = devices.ELEC_INTERFACE, value_down =  1.0,  value_up = 0.0,  name = _('Pitot Heater Switch - ON/AUTO'),  category = {_('Right Console'), _('ECS Panel')}},

I am assigning the command to a WH throttle maintained 2-position switch. Now this line should make the switch operate the ON and AUTO functions depending on switch position, but instead it operates both ON and AUTO functions in the switch down position. That is: switch down for ON, switch up does nothing, Switch down for AUTO, Switch up does nothing. Is this a bug? Any ideas on how to achieve my switch objective?

Link to comment
Share on other sites

Something has changed in the F/A-18C joy default.lua. Both the joystick and the keyboard file have the same line to control the Pitot heater switch on the right console:

 

{down = elec_commands.PitotHeater, up = elec_commands.PitotHeater, cockpit_device_id = devices.ELEC_INTERFACE, value_down =  1.0,  value_up = 0.0,  name = _('Pitot Heater Switch - ON/AUTO'),  category = {_('Right Console'), _('ECS Panel')}},

I am assigning the command to a WH throttle maintained 2-position switch. Now this line should make the switch operate the ON and AUTO functions depending on switch position, but instead it operates both ON and AUTO functions in the switch down position. That is: switch down for ON, switch up does nothing, Switch down for AUTO, Switch up does nothing. Is this a bug? Any ideas on how to achieve my switch objective?

Nothing has changed. See post #739 for a solution.

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

Hi All,

is it possible to cycle through more than 1 or 2 "buttons", e.g. button a, followed by b , c, d, e and then back to a again?

SYSTEM SPECS: Hardware Intel Corei7-12700KF @ 5.1/5.3p & 3.8e GHz, 64Gb RAM, 4090 FE, Dell S2716DG, Virpil T50CM3 Throttle, WinWIng Orion 2 & F-16EX + MFG Crosswinds V2, Varjo Aero
SOFTWARE: Microsoft Windows 11, VoiceAttack & VAICOM PRO

YOUTUBE CHANNEL: @speed-of-heat

1569924735_WildcardsBadgerFAASig.jpg.dbb8c2a337e37c2bfb12855f86d70fd5.jpg

Link to comment
Share on other sites

not that I know.

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

  • Recently Browsing   0 members

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