Jump to content

Buttons triggered & functions executed?


Lumax

Recommended Posts

Hello lads.

 

Since DCS has soooo many keys that to activate/deactivate systems

I want to create a switch/toggle function addon, mod or whatever you guys call it.

 

Basically what i want to do is to make button X on my joystick switch between different systems. Ie. same as keyboard key 1,2,3,4,5,6...

 

So each time i press down joystick_btn X i want to increase my ""counter"" by 1.

 

I already posted my question in the Input & ... Thread. but i feel it more it belongs in this section of the forum.

 

My questions are.

* How do i get the "event" when i press my joystick button X.

* How do i get this to fire up my own function?

 

 

As to my 1st question i guess its possible since in this directory:

C:\Games\DCS World\Scripts\Input\InputEvents.lua

 

is see this

addEvent("JOY_BTN16", JOYSTICK_BUTTON15)

Which is the button i want to use.

 

I guess addEvent is some sort of function that takes a string name as its 1st argument. but what is the second one? a value ? a function ? ..

 

 

basically what i want to do is toggle between some states when i press the same button. example.

 

MY_var = 0
function MY_weaponselector()
   local weaponOrderlist = {
       "Select Weapon AA 1",
       "Select Weapon AA 1-2",
       "Select Weapon AA 2",
       "Select Weapon AA 3",
       "Select Weapon AA 3-4",
       "Select Weapon AA 4",
       "Select Weapon B 1-2 / UB-16"
       "Select Weapon B 1-4 / UB-4",
       "Select Weapon B 3-4 / UB-8",
       "Select Weapon S-24 1-2",
       "Select Weapon S-24 3-4"}
   
   MY_var = MY_var + 1
   --  length of MY_var --
   -- reset and start at 1st weapon again --
   if MY_var > 11: 
       MY_var == 0
   
   action = weaponOrderlist[MY_var]
   print "howto execute action?"

im not sure how to put this all together and make it work.

could anyone please help me with this?

 

..

Link to comment
Share on other sites

I don't think this is possible with plain LUA here.

 

I think, InlutEvents.lua only maps the human readable DX button name to the internal DX button IDs. The event processing of the DX button presses is most likely not directly accessible by means of LUA programming.

 

How I imagine it:

- User presses a button (i.e. "Fire")

- Windows/DirectX tells DCS that a button was pressed (i.e. 0xc01dcafe)

- DCS looks up the "DCS name" of the DX button in the table that was populated by addEvent() in InputEvents.lua (i.e. inputEvents[0xc01dcafe] = "JOY_BTN1")

- DCS determines what to do now in the aircraft specific input configuration (controls mapping, clickabledata.lua, etc.)

- DCS dispatches this mapped function to the aircraft logic (most probably located in a .dll)

 

So atm, I would suspect you can make your approach only work if you modify the aircraft itself. You could probably add a new virtual cockpit device (in LUA) that gets triggered by your button which then fires your desired events.

 

Not really a viable approach, I'd think ...

 

Others have experimented with the respective joystick programming software to create such kind of "macros". Also not the most elegant way to do, imho, but probably way more viable and effective to accomplish the desired result.

Link to comment
Share on other sites

Others have experimented with the respective joystick programming software to create such kind of "macros". Also not the most elegant way to do, imho, but probably way more viable and effective to accomplish the desired result.

 

Yes. That could be done with Thrustmaster's Target software but otherwise I don't know.

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

  • Recently Browsing   0 members

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