Jump to content
Sign in to follow this  
MarkDH

Synchronize FSX with your switches

Recommended Posts

I have written a function that scans all of the switches on all of the joysticks you have connected and determines whether each switch is ON or OFF. It then calls the Lua functions you have associated with those switches in LINDA. This ensures that your FSX aircraft is in sync with your switches. It seems to work pretty well for me, so I am uploading it here for people to try out.

 

To use this, just download the file and put it in your fsx\modules\linda\libs folder, then you can call the function, SYNC_Aircraft_To_Switch_Settings(), by linking it to a button. The only thing to note is that this will never call any Lua function with the word 'toggle' in its name.

 

If you want to try this out, you can download the file here.

 

Let me know how it works for you!


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

Can you post it here?  I don't have an account there.

 

Well no, I can't seem to add attachments here. However, I have added a reply to the post linked above with the text of the Lua file. Just create your own text file and paste the text into it.


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

I'll try it out.  (I wish developers would avoid toggle commands).


Gregg Seipp

"A good landing is when you can walk away from the airplane.  A great landing is when you can reuse it."
i7-8700 32GB Ram, GTX-1070 8 Gig RAM

Share this post


Link to post
Share on other sites

I'll try it out.  (I wish developers would avoid toggle commands).

 

Yes, toggles really screw things up :(


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

:smile:Thank you.

Now to try it....

Didn't work.  I have 5 controller boards that I use for switches and buttons.  Should I have to edit anything to get the script to see them?  Linda sees the boards.

 

Is it sufficient to assign the script to the default aircraft in FSX to have it work with any aircraft or do I have to assign it for each aircraft I use?  (dodo and some asa aircraft)

 

The ShowMessageWindow("Scanning switches...") never shows.

Linda Console says attempt to call global 'ShowMessageWindow' (a nil value)

Share this post


Link to post
Share on other sites

Commenting out the ShowMessage, ShowMessageWindow and HideMessageWindow calls allowed it to work, somewhat.

 

It missed a couple of switches. Could this be a timing issue???

 

Also, one of my controllers has 64 buttons.  Can this routine handle it?

Share this post


Link to post
Share on other sites

 

 


I'll try it out. (I wish developers would avoid toggle commands).

 

It's not always the developers fault, they're just using the standard FSX commands in many of those cases.  There's an annoying amount of those that are toggles.

 

However, the way around (with something like LINDA, or using the built-in FSUIPC functionality) it is to write Lua code that checks the state of the item in the simulator being toggled, before it actually activates the toggle. That way, it's impossible to get a switch out of sync.  However, to keep from having switches start off being out of sync, something like what the OP has done is very useful.

 

It's possible to have Lua code that automatically polls the status of both the sim and the switches, but you have to be really careful or else you can quickly add a performance penalty.


Jim Stewart

Milviz Person.

 

Share this post


Link to post
Share on other sites

to write Lua code that checks the state of the item in the simulator being toggled, before it actually activates the toggle

Jimmy, that is brilliant and I am going to try to add it to those of my LINDA functions built around toggles (the RXP GPS ON/OFF, for example, is a recurrent pain)!

Commenting out the ShowMessage, ShowMessageWindow and HideMessageWindow calls allowed it to work, somewhat.

 

It missed a couple of switches. Could this be a timing issue???

 

Also, one of my controllers has 64 buttons. Can this routine handle it?

Last one first - no, it will not handle 64-button controllers as FSUIPC does not handle them.

 

The ShowMessage puzzles me, but try moving the message functions to the top of the file. That error suggests they need to be defined above the main function. (I already have these functions defined in a different library so this may be hiding the problem for me.) The ShowMessage stuff slows it down too, but as this takes 10+ seconds to run (for me) any way I think it's better to see that something is happening.

 

It seems crucial for me to discover how it missed some functions. It would helpful if you could uncomment ALL the ipc.log calls in the code and then send me (or post here) the log (copied from fsuipc.log). You may have some switch combinations that I have not anticipated. You will also need to say which ones were missed and, if possible, something about the switch (e.g. if it is part or an ON-OFF-ON or an ON-ON-ON switch). It may be able the order in which the LINDA functions are called that's the issue.

 

Thanks for trying!


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

Moving the message functions to the top fixed that....except the message window doesn't close.

 

The switches that are missed are either greater than 32 or on a controller that only temporarily shows them as on.  IE, when the toggle is thrown the on condition shows for about 1 sec then goes off.  This is by design.  Hence, your software has no idea what the state of the switch would be. 

 

That said, except for the window not closing, everything seems to be working great.

Share this post


Link to post
Share on other sites

The switches that are missed are either greater than 32 or on a controller that only temporarily shows them as on.  IE, when the toggle is thrown the on condition shows for about 1 sec then goes off.

 

Ah, interesting. How do you normally use those momentary switches? I would have thought they would only be useful with toggled functions, unless you have them connected to something other than FSUIPC. I have checked out the Message functions and there were indeed issues. You can re-download the file (or text), or you can fix yours by changing the second-last line of the function to read

    HideMsgWindow("Setting OFF actions")

instead of

    HideMsgWindow("")

MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

The momentary toggles are an artifact of another application.  A flight game that only read push buttons.  I can't remember its name.  I just redid the settings and converted the momentary setting to toggle.  Everything is fine now (for buttons less than 33).

Share this post


Link to post
Share on other sites

Is there a way to active this routine from a key press? 

 

Reason: using VAC (voice active commands), I already synchronize Linda by sending a key string to Autohotkey which moves the mouse to click on the sync button in Linda.

Using the same Autohotkey routine, I'd also like to run the script after Linda in synchronized with FSX.  So a key press or function call (outside of Linda) would be great. 

Share this post


Link to post
Share on other sites

Is there a way to active this routine from a key press? 

 

I have a feeling this discussion has happened before - can LINDA functions be triggered from keypresses? I do not know a way, but perhaps someone else will comment.


MarkH

gGzCVFp.jpg
Core i7-7700K / 32Gb DDR4 / Gigabyte GTX1070 / 1080p x 3 x weird / Win7 64 Pro

Share this post


Link to post
Share on other sites

I changed the HideMsgWindow call to have ("Setting OFF actions").

Window still doesn't disappear and the Linda console says:

211: attempt to call global "HideMsgWindow' (a nil value)

 

I think the problem is the call is to HideMsgWindow and your function is called HideMessageWindow.

 

I'll name them the same.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...