Jump to content
The simFlight Network Forums

Read L:Var


Framac

Recommended Posts

Hi,
Is it possible to read one L:var value with offset 0x0D70 without macro files?
I just want to read the value of one L:var and did not intend to create a macro file or use LUA just for this purpose.
I'm using C#
Thank you for the help. :)
Framac

 

Link to comment
Share on other sites

Hi Thomas
Thank you for your answer.

I try but I'm doing something wrong.

The L:Var is an int :  VC_GSLD_CP_EFIS_ND_Mode_Knob
I have the two offets
        public static Offset<string> offset_sendlvar = new Offset<string>(0x0d70, 40, true);
        public static Offset<int> offset_readlvar = new Offset<int>(0x66c0, true);

        offset_sendlvar.Value = "0x666c0:VC_GSLD_CP_EFIS_ND_Mode_Knob";
        FSUIPCConnection.Process();

        int  test= offset_readlvar.Value;

But this always return 0
 

What I'm doing wrong? Can you help me?
Thank you

Framac

Link to comment
Share on other sites

Yes, you are right, but even in R / W mode I can not get the value of LVar.
I do not know if this is the right way to write the value to the offset 0x0D70
        offset_sendlvar.Value = "0x366c0:LVAR_Name";

This is my code right now and only return zero. :(
         ...
        public static Offset<string> offset_sendlvar = new Offset<string>(0x0d70, 40);
        public static Offset<int> offset_readlvar = new Offset<int>(0x66c0);
       ...
        offset_sendlvar.Value = "0x366c0:VC_GSLD_CP_EFIS_ND_Mode_Knob";
        FSUIPCConnection.Process();
        ...
        int  test= offset_readlvar.Value;

I am not asking you to do the work for me but I think a little help with a more detailed answer would be useful not only for me but also for future users who have this problem.
Sometimes the problem is in front of our eyes and we can not see it.
Some of us are not professional developers and any small answer is a big help.  :)

Thank you for your help
.

Framac

Link to comment
Share on other sites

Here is the relevant documentation:

Quote

L:Vars can now be read and written through offsets as well as with Lua plug-in functions. This re-uses the offsets provided for
executing macros and Lua plug-ins, as follows:


0D6C 4 bytes Write here the offset to which the resulting value (an 8-byte double or FLT64) will be written,
or the value to be written can be found.
This MUST be one of the user offsets, i.e. in the range 0x66C0 to 0x66F8.


0D70 40 bytes Write here the name of the LVar, preceded by just one : (colon) for a read or :: (two colons) for a
write,
and terminated by a zero byte.

So you need to also declare another offset (before 0D70) of type int for 0x0D6C. In there you need to write the offset you'll be using to receive, along with the type code. In this case 0x366C0. (int at 66C0). Write this as a number obviously, not as a string.

Then in 0D70 you just write the LVar name preceded by a single colon (meaning read):
 

offset_sendlvar.Value = ":VC_GSLD_CP_EFIS_ND_Mode_Knob";

After processing, 0x66C0 will now contain the value.

Paul

 

Link to comment
Share on other sites

  • 1 year later...

Hello,

view Days ago i chnged from SharpDevelop to VS2017.

That is my first NugetPackage i installed. Hope i did all right, but for the Moment i get no error when i try to compile the Programm with 

FSUIPCConnection.WriteLVar(Name, NewValue)

No i will try to see if it works.

Thanks for the moment, i will come back 🙂

Matthias

Link to comment
Share on other sites

It's just a standard .NET class library dll.

If you installed it via NuGet then it has been automatically added as a reference. Check the references for your project and you'll see it. The actual dll file will be copied to your build folder (debug/release) as normal.

I think the official SDK has a very old version of the dll (maybe 2.0). A lot of new stuff went into 3.0 including the LVar read/write.

I moved to NuGet as it's much easier to publish new versions and keep everyone alerted to new builds.

Paul

Link to comment
Share on other sites

Hello again,

 

i have a new/another Problem.

I have to send "TAB+1" to Prepar3D to open my Doors.

I found you thread: 

but it dosent work for TAB+1

i tried it with                  controlParameter.Value = (int)Keys.Tab + (49);

Also Prepar3D does not become the Focus and also i can not send STRG with

controlParameter.Value = (int)Keys.RControlKey + (49);

but with 

controlParameter.Value = 512 + 49;

it works ???

I just wonder why it works with 512 and not with Keys.RControlKey ???

Can you please help here a bit ?7

Thanks

Matthias

 

Link to comment
Share on other sites

Hi Matthias,

There is now a function in the DLL to send key presses to the sim. Sending Tab+1 would be this:

FSUIPCConnection.SendKeyToFS(Keys.D1, SendModifierKeys.Tab);

This also takes care of setting focus to the sim first.

If you want to return focus to your own application, include a reference to this form as the last parameter. For example if the code is part of the form class:

FSUIPCConnection.SendKeyToFS(Keys.D1, SendModifierKeys.Tab, this);
Quote

I just wonder why it works with 512 and not with Keys.RControlKey ???

The modifiers in the .net "Keys" enum are not the same as the modifier codes used by FSUIPC. I had to make my own enum for the DLL (SendModifierKeys).

For future questions, please make a new thread in my sub forum.

Kind Regards,

Paul

Link to comment
Share on other sites

Hello,

thats so fast 🙂

Hmmm...no, i need that FS becomes the Focus before the Key is send 🙂

But i remember there was a DLL import and setforegroundwindow function for that.

Ahh, one thing ... if i call FSUIPCConnection.... is there maybe any funktion in your dll to ceck if FSUIPC is available ( FS running ) or did your dll check that ?

Matthias

Link to comment
Share on other sites

Quote

Hmmm...no, i need that FS becomes the Focus before the Key is send

Yes that's what the DLL does. It first gives focus to the flight sim. Then it sends the key you requested.

It will then restore the focus to your own application window. But only if you ask it to (third parameter).

Quote

if i call FSUIPCConnection.... is there maybe any funktion in your dll to ceck if FSUIPC is available ( FS running ) or did your dll check that ?

When you call FSUIPCConnection.Open() it will thrown an exception if a flight sim or WideClient.exe is not running. You should catch these exceptions to know that FS is not running.

When you call other functions that talk to FSUIPC e.g. Process() or SendKeyToFS(), these will also throw exceptions if the connection has been lost.

You can examine the FSUIPC Application Templates to see the recommended way to handle the connection management.

http://fsuipc.paulhenty.com/#downloads

Paul

Link to comment
Share on other sites

Hello again,

a very litle problem.

I try to send FSUIPCConnection.SendKeyToFS(Keys.F12, SendModifierKeys.Control);

to Prepar3D v4.4 to open the GSX Menu, but P3D becomes the Focus, but the Key is not send or something.

When i put a Sleep before the FSUIPCConnect command and click on the Prepar3D window to activate it, then it works.

Have you any ideas ?

Matthias

Link to comment
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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.