Jump to content

Multiple keys mapped to one key or button - possible?


Recommended Posts

Hi guys

 

Just wondering if it's possible within DCS (without using external tools) to somehow map multiple functions to one button or key. Doesn't matter if they are executed simultaneously or with slight delay.

 

Cheers!

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Hi guys

 

Just wondering if it's possible within DCS (without using external tools) to somehow map multiple functions to one button or key. Doesn't matter if they are executed simultaneously or with slight delay.

 

Cheers!

 

Within DCS you can't as it won't let you. Did you try using your HOTAS software and map to 2 commands?

Link to comment
Share on other sites

Ok cheers guys. Was hoping there might be a way to do it in DCS, juggling lua and all that. But if there is not, I'll use external tools. Was hoping to avoid that, because different planes will need different profiles. I'll look into JoyToKey. Thanks!

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

JoyToKey, does it.

 

I remember mapping both NGMR and Target Unlock (F15C) to NWS button for X55.

You need to assaign keyboard controls from DCS. Play around with JoyToKey, I'm sure you'll find it.

That little software has some good options. You can also map long presses and cycles too.

 

looks interesting is it as good as Saitek Smart Technology?

Link to comment
Share on other sites

Ok cheers guys. Was hoping there might be a way to do it in DCS, juggling lua and all that. But if there is not, I'll use external tools. Was hoping to avoid that, because different planes will need different profiles. I'll look into JoyToKey. Thanks!

 

Well, when you said "no external tools" I read that as "within game only". Lua is an external tool, just one that DCS uses heavily.

 

If you're allowing "juggling luas", that's not terribly difficult...if you want to talk specifics, feel free to post some more details of exactly what you want to do either here in the thread or PM me.

 

Teej

 

Note: The following are both valid scenarios - the specifics are just to put a context around things - that's why I say be very specific about what you want - the details of the answer depend on the details of the question...

 

1: "I want DCS to drop my flaps any time I drop my gear"

 

2: "I want a new entry in DCS controls that will do both - drop my flaps and gear, without changing what happens with the normal flaps / gear keys"


Edited by Teej

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

Well, when you said "no external tools" I read that as "within game only". Lua is an external tool, just one that DCS uses heavily.

 

If you're allowing "juggling luas", that's not terribly difficult...

 

Point taken regarding LUA. I considered that part of the game (although I'm aware that it's an independent scripting language). Should have been clearer in my OP.

 

Thing is, I do speak several programming languages fluently (for a living), but I have absolutely no idea about LUA. If you could give me pointers regarding the two scenarios you mentioned, that would probably get me started:

 

1: "I want DCS to drop my flaps any time I drop my gear"

 

2: "I want a new entry in DCS controls that will do both - drop my flaps and gear, without changing what happens with the normal flaps / gear keys"

I'm pretty sure that once I understand how keys are mapped within LUA, and which files to look at, I could probably work it out from there, so if you have any examples at hand, that would be absolutely awesome (can be any plane really, as I have most of them).

 

Or if you want specific use cases, here are a few I was curious about (regardless of whether it's sensible in a combat/sim context):

 

1. how can I drop flares and chaffs simultaneously with a single key press on the Mirage? (They are separate keys as of now)

 

2. For the MiG 21, I'd like to switch IR/SAR and the right pylons at the same time, as well as the radar mode (beam, cone style scan)

 

3. For the Sabre, I'd like the air brake to be a toggle switch, not two buttons for airbrake out and in

 

EDIT:

4. Advanced case for the MiG 21, a kind of key rotation with one button: Gear down, neutral, Gear up, neutral. Same for flaps.

 

 

And the list continues as I learn more about the aircraft and which mappings might work best for me :music_whistling:

 

Cheers!


Edited by Lucifah

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Let's start here. Keep in mind I'm writing this without direct access to DCS at the moment, so I might have goofed something up. It will show you all the necessary parts, however...

 

OK. Given your programmer background, this will generally be pretty easy to get you through…but recognize it won’t pass an “integrity check” so if you’re attempting to use these to your advantage in a multiplayer scenario, please don’t try :D

 

LUA is a full-on scripting language, and what you’ve seen with the keymapping is only a piece of it. What I’ll show you is how you can have a piece of LUA code called whenever you hit specific commands. At that point, you can either issue additional commands on the back end, or (using typical programming control logic) decide what to do.

 

Let’s say I want to make it so when I hit “LeftAlt-V” my gear and flaps are lowered.

 

The first thing I need to do is go into my mods/aircraft/[mod]/input/[airframe]/keyboard/default.lua file. Somewhere in the middle of the file that makes sense to me…like…near the commands you want to duplicate, add a line like this:

 

{combos = {{key = 'V', reformers = {'LAlt'}}}, down = 7000, name = ‘Gear and Flaps Down’, category = ‘Lucifah’},

 

What this means is that when you hit “LAlt-V, it will send a command “7000” (As far as I’m currently aware, anything over 4000 should be OK and won’t conflict with DCS any time soon) to DCS. It will show in the keymap settings as “Gear and Flaps Down” and it can also be seen if you click the category at the top and select “Lucifah”. This lets you group whatever custom work you do together…

 

DCS doesn’t know what command 7000 means - and that’s a good thing. We’re going to tell it. You see, DCS doesn’t directly know when you hit a certain keypress, there’s an input processor that converts your key / axis inputs into “command” codes. Most of what you see in the default.lua file is “friendly names” like “iCommandPlaneGearDown”, but they all translate to codes…. gear down is 431, flaps down (landing flaps) is 145.

 

So now let’s go to your aircraft’s cockpit/scripts folder. Among other things there should be 2 files we’re interested in… “devices.lua” and “device_init.lua”. If those don’t exist, that’s not necessarily a big deal. For now let’s assume they do. Open up devices.lua.

 

You should see something like:

 

local count = 0
local function counter()
count = count + 1
return count
end
-------DEVICE ID-------
devices = {}
devices["ccKneeboard"] = counter() -- 1

 

 

We’re going to add another device. Assuming you have the devices=() line, then after the last “devices” line listed, add one more:

devices[“MyDevice”] = counter() — 2 (the — makes things a comment, the number is just there for your reference/debugging if it ever becomes necessary)

 

Save the file and open device_init.lua

 

Hopefully you have a section of code that starts similar to:

creators = {}
creators[devices.ccKneeboard] = {"avKneeboard",LockOn_Options.common_script_path.."KNEEBOARD/device/init.lua"}

 

Let’s add the following in that section…

creators[devices.MyDevice] = {“avLuaDevice”,”MyCode.lua”}

 

Put this way, it’s going to look for a .lua called “MyCode” located in your DCS root folder (ie c:\program files\DCS World). Trying not to get too deep with customizing everything all at once…

 

Save that file. Now let’s go to your DCS root folder and create MyCode.lua Let’s make the contents:

 

—  <- remember — makes a line a comment
— Get handle to device code:
local MyCode = GetSelf()

— “subscribe” to command 7000 (as defined above in the keyboard default.lua we changed above).   
— Whenever DCS gets a 7000, it will call this file’s SetCommand function.
MyCode:listen_command(7000)


— So when we get called, if the command is 7000, we’ll drop the gear and flaps.
function SetCommand(command,value)
if (7000 == command) then
	dispatch_action(nil,431)
	dispatch_action(nil,145)
—	elseif (7001 == command) then
—		— do something else
—	end
end
end


Edited by Teej
  • Like 1

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

Let's start here. Keep in mind I'm writing this without direct access to DCS at the moment, so I might have goofed something up. It will show you all the necessary parts, however...

 

You're a rockstar, mate! That'll get me started for sure (contains more than I ever expected). Thanks for that.

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Teej you really rocks, but.. I have one specific - it is possible (this way or another) to assign throttle axis to mouse scroll wheel? this is my all time favorite nut to crack in DCS :)

 

I did try adding simple line into mouse.lua but no luck, wondering if some kind of 'complicate' workaround will work

Link to comment
Share on other sites

       dispatch_action(431)

 

Are you sure that dispatch_action() is the right function to use? I only found one use of it in other scripts, and that used three parameters.

 

Everything else works fine. Got my button assigned, and it's calling my code correctly, which I have verified with print_message_to_user() on entry and exit of the SetCommand function to be sure it doesn't break in the middle. (Since I haven't got a clue yet as to how to debug things otherwise.)

 

Just can't get it to actually issue any commands via dispatch_action(). (I have tried other standard values for different functions, which I gathered from Export.lua)

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

That's one of those things I thought I might have goofed.... make it:

 

dispatch_action(nil,431)

 

I've never seen anything but "nil" in the first parameter...and the third parameter is for an axis...like joystick pitch. If it makes you feel better, use (nil,431,0) :D

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

Teej you really rocks, but.. I have one specific - it is possible (this way or another) to assign throttle axis to mouse scroll wheel? this is my all time favorite nut to crack in DCS :)

 

I did try adding simple line into mouse.lua but no luck, wondering if some kind of 'complicate' workaround will work

 

Hmmm. I didn't have any trouble. Went into my mouse default.lua, commented out the existing MOUSE Z line and inserted:

 

{combos = {{key = 'MOUSE_Z'}}, action = iCommandPlaneThrustCommonDelta, name = 'Mouse Thrust'},

 

Then launched the game went to axis settings, clicked on the "Mouse Thrust" Mouse Z entry and chose "axis tune" and turned on invert & slider checkboxes.

 

Worked for me.

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

That's one of those things I thought I might have goofed.... make it:

 

dispatch_action(nil,431)

 

I've never seen anything but "nil" in the first parameter...and the third parameter is for an axis...like joystick pitch. If it makes you feel better, use (nil,431,0) :D

 

 

Ok cheers, that works now, but not for the Sabre's air brake. That's because it's a customised function for that plane, and even the default assignments they kept in there have no effect whatsoever for the same reason. :noexpression:

 

Oh well, thanks for your help anyway! I'm sure I will use that elsewhere :smilewink:

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

That can still work. The advanced systems just add a step or two.

 

Paste in here the lines from the sabre's keyboard default.lua file that reference the speedbrake commands you want to use as well as cut & paste the list of devices from devices.lua.

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

Will do tomorrow evening, if I can squeeze that in. Got a bit of a busy day ahead. Thanks again!

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Hmmm. I didn't have any trouble. Went into my mouse default.lua, commented out the existing MOUSE Z line and inserted:

 

{combos = {{key = 'MOUSE_Z'}}, action = iCommandPlaneThrustCommonDelta, name = 'Mouse Thrust'},

 

Then launched the game went to axis settings, clicked on the "Mouse Thrust" Mouse Z entry and chose "axis tune" and turned on invert & slider checkboxes.

 

Worked for me.

 

Teej, probably it wasnt problem in the past, but now this doesnt do a thing. No luck. The axis value just oscillates around the center in the "axis tune"and thats it, no move in game.

Could you pls think of any other way to do this?

 

Lucifah sry for using your thread ;)

Link to comment
Share on other sites

Lucifah sry for using your thread ;)

 

That's alright. It's related :smilewink:

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Teej, probably it wasnt problem in the past, but now this doesnt do a thing. No luck. The axis value just oscillates around the center in the "axis tune"and thats it, no move in game.

Could you pls think of any other way to do this?

 

I meant that I did that just before posting it. Flew around for 5-10 minutes like that.

 

I did that in 2.0 alpha though. Hmmm.

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

Actually, I bet I know why it's not working for you. I did it in an SFM jet and you're probably trying to do it in a newer AFM/ASM setup that doesn't support the ...ThrustCommonDelta parameter.

 

Got an idea what needs to be done for AFM/ASMs...lemme try on one of mine and get back to you...Won't be quite a cut-and-paste thing - it'll probably need a small change for every plane you want to use it on.

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

That can still work. The advanced systems just add a step or two.

 

Paste in here the lines from the sabre's keyboard default.lua file that reference the speedbrake commands you want to use as well as cut & paste the list of devices from devices.lua.

 

 

Alright, here it goes...

 

default.lua:

 

-- Systems
-- air brake
{combos = {{key = 'B', reformers = {'LAlt','LShift'}}},    down = iCommandPlaneAirBrake,                                                                                    value_down = 1,        name = _('Speed Brake Switch - Up'),    category = {_('Flight Control'), _('Throttle Grip')}},
{combos = {{key = 'B', reformers = {'LAlt','LCtrl'}}},    down = iCommandPlaneAirBrake,                                                                                    value_down = -1,    name = _('Speed Brake Switch - Down'),    category = {_('Flight Control'), _('Throttle Grip')}},
{combos = {{key = 'B', reformers = {'LShift'}}},        down = hydro_commands.F86_CockpitDeviceCommand_AirBrakesHandle,    cockpit_device_id = devices.HYDRO_INTERFACE,    value_down = -1,    name = _('Speed Brake Switch - OUT'),    category = {_('Flight Control'), _('Throttle Grip')}},
{combos = {{key = 'B'}},                                down = hydro_commands.F86_CockpitDeviceCommand_AirBrakesHandle,    cockpit_device_id = devices.HYDRO_INTERFACE,    value_down = 0,        name = _('Speed Brake Switch - HOLD'),    category = {_('Flight Control'), _('Throttle Grip')}},
{combos = {{key = 'B', reformers = {'LCtrl'}}},            down = hydro_commands.F86_CockpitDeviceCommand_AirBrakesHandle,    cockpit_device_id = devices.HYDRO_INTERFACE,    value_down = 1,        name = _('Speed Brake Switch - IN'),    category = {_('Flight Control'), _('Throttle Grip')}},

I need OUT and IN. Hold is the middle position on the rocker switch, which does nothing useful. Up/Down don't do anything at all.

 

 

And the devices.lua:

 

local count = 0
local function counter()
   count = count + 1
   return count
end
-------DEVICE ID-------
devices = {}
-- moved forward for correct initialization of another devices
-- do not changed folowing sequence for sim
devices["ELEC_INTERFACE"]            = counter()    -- 1
devices["HYDRO_INTERFACE"]            = counter()
devices["FUEL_INTERFACE"]            = counter()
devices["ENGINE_INTERFACE"]            = counter()
devices["WEAPON_SYSTEM"]            = counter()    -- 5
devices["AIR_SPEED_INDICATOR"]        = counter()
devices["BARO_ALTIMETER"]            = counter()
devices["VARIOMETER"]                = counter()
devices["MACH_INDICATOR"]            = counter()
devices["CLOCK"]                    = counter()    -- 10
devices["TURN_SLIP_INDICATOR"]        = counter()
devices["ACCELEROMETER"]            = counter()
devices["CONTROL_INTERFACE"]        = counter()
devices["OXYGEN_INTERFACE"]            = counter()
devices["FIRE_DETECTION_INTERFACE"]    = counter()    -- 15
devices["AIR_INTERFACE"]            = counter()
devices["LIGHT_INTERFACE"]            = counter()
devices["NAV_LIGHTS_INTERFACE"]        = counter()
devices["STANDBY_COMPASS"]            = counter()
devices["GYROMAG_COMPASS"]            = counter()    -- 20
devices["AN_APG_30"]                = counter()
devices["A4_GUNSIGHT"]                = counter()
devices["FM_PROXY"]                    = counter()
devices["ATTITUDE_INDICATOR"]        = counter()
devices["COCKPIT_MECHANICS"]        = counter()    -- 25
devices["AN_ARC_27_COMMAND_SET"]    = counter()
devices["AN_ARN_6_RADIO_COMPASS"]    = counter()
devices["MACROS"]                    = counter()
devices["AN_APX6_IFF"]                = counter()
devices["INTERCOM"]                    = counter()    -- 30

devices["ARCADE"]                    = counter()
devices["KNEEBOARD"]                 = counter()

devices["HEARING_SENS"]                = counter()

devices["AIRBRAKE_TOGGLE"]            = counter()

Ignore the last one (AIRBRAKE_TOGGLE). That's from my attempts to make it work.

 

To me it looks like the actual functionality is buried in DLL files, but I don't have time and inclination to debug/disassemble them. I doubt they'd be compiled with debug symbols anyway, so that would get rather very tedious to do and is probably not worth it.

 

But if you can make anything of those bits up there, please do share :smilewink:

 

Cheers!

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Something strange happening in this thread. A thread reply (got the email notification) doesn't show here, and I apparently cannot send you a private message either. It's not showing there after sending. :huh:

 

The powers that be [tm] apparently don't want this discussed. Very odd.

If a moderator is involved here, please could you clarify if anything we discussed here was not okay to be discussed? :helpsmilie:

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Oh for...no, a mod didn't delete my post, I did, and I did get your PM. ;) PMs don't save in your out box here by default.

"Tank! I need a program for a TM Warthog!"

 

[sIGPIC][/sIGPIC]

Virtual Thunderbirds, LLC | Sponsored by Thrustmaster

 

Thermaltake V9 SECC case | Corsair RM750 PSU | Asus ROG Ranger VIII | Intel i7 6700K | 16GB 3000mhz RAM |

EVGA GTX 980Ti FTW | TrackIR 4 w/ pro clip | TM HOTAS Warthog | TM MFD Cougar Pack | Win 10 x64 |

Link to comment
Share on other sites

Oh for...no, a mod didn't delete my post, I did, and I did get your PM. ;) PMs don't save in your out box here by default.

 

Oh alright then. :)

My humble rig: Windows 10 pro 64bit; i7-6700k on Gigabyte Z170X G7; 32GB; MSI 980ti Twin Frozr; 512GB Samsung 950 Pro (NVMe/PCIe x4); 1TB Samsung 850 Pro; Komplete Audio 6; TrackIR 5 Pro;

DCS 2.5 with almost all modules; favourites: Shark, Mi-8, Harrier, Viggen, Mirage, Hornet

Link to comment
Share on other sites

Let's start here. Keep in mind I'm writing this without direct access to DCS at the moment, so I might have goofed something up. It will show you all the necessary parts, however...

 

OK. Given your programmer background, this will generally be pretty easy to get you through…but recognize it won’t pass an “integrity check” so if you’re attempting to use these to your advantage in a multiplayer scenario, please don’t try :D

 

LUA is a full-on scripting language, and what you’ve seen with the keymapping is only a piece of it. What I’ll show you is how you can have a piece of LUA code called whenever you hit specific commands. At that point, you can either issue additional commands on the back end, or (using typical programming control logic) decide what to do.

 

Let’s say I want to make it so when I hit “LeftAlt-V” my gear and flaps are lowered.

 

The first thing I need to do is go into my mods/aircraft/[mod]/input/[airframe]/keyboard/default.lua file. Somewhere in the middle of the file that makes sense to me…like…near the commands you want to duplicate, add a line like this:

 

{combos = {{key = 'V', reformers = {'LAlt'}}}, down = 7000, name = ‘Gear and Flaps Down’, category = ‘Lucifah’},

 

What this means is that when you hit “LAlt-V, it will send a command “7000” (As far as I’m currently aware, anything over 4000 should be OK and won’t conflict with DCS any time soon) to DCS. It will show in the keymap settings as “Gear and Flaps Down” and it can also be seen if you click the category at the top and select “Lucifah”. This lets you group whatever custom work you do together…

 

DCS doesn’t know what command 7000 means - and that’s a good thing. We’re going to tell it. You see, DCS doesn’t directly know when you hit a certain keypress, there’s an input processor that converts your key / axis inputs into “command” codes. Most of what you see in the default.lua file is “friendly names” like “iCommandPlaneGearDown”, but they all translate to codes…. gear down is 431, flaps down (landing flaps) is 145.

 

So now let’s go to your aircraft’s cockpit/scripts folder. Among other things there should be 2 files we’re interested in… “devices.lua” and “device_init.lua”. If those don’t exist, that’s not necessarily a big deal. For now let’s assume they do. Open up devices.lua.

 

You should see something like:

 

local count = 0
local function counter()
count = count + 1
return count
end
-------DEVICE ID-------
devices = {}
devices["ccKneeboard"] = counter() -- 1

 

 

We’re going to add another device. Assuming you have the devices=() line, then after the last “devices” line listed, add one more:

devices[“MyDevice”] = counter() — 2 (the — makes things a comment, the number is just there for your reference/debugging if it ever becomes necessary)

 

Save the file and open device_init.lua

 

Hopefully you have a section of code that starts similar to:

creators = {}
creators[devices.ccKneeboard] = {"avKneeboard",LockOn_Options.common_script_path.."KNEEBOARD/device/init.lua"}

 

Let’s add the following in that section…

creators[devices.MyDevice] = {“avLuaDevice”,”MyCode.lua”}

 

Put this way, it’s going to look for a .lua called “MyCode” located in your DCS root folder (ie c:\program files\DCS World). Trying not to get too deep with customizing everything all at once…

 

Save that file. Now let’s go to your DCS root folder and create MyCode.lua Let’s make the contents:

 

—  <- remember — makes a line a comment
— Get handle to device code:
local MyCode = GetSelf()

— “subscribe” to command 7000 (as defined above in the keyboard default.lua we changed above).   
— Whenever DCS gets a 7000, it will call this file’s SetCommand function.
MyCode:listen_command(7000)


— So when we get called, if the command is 7000, we’ll drop the gear and flaps.
function SetCommand(command,value)
if (7000 == command) then
	dispatch_action(nil,431)
	dispatch_action(nil,145)
—	elseif (7001 == command) then
—		— do something else
—	end
end
end

Teej, this is very interesting! But...

1. where do I find all the action codes?

2. are they the same for all modules?

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...