Jump to content
The simFlight Network Forums

using custom offset to trigger event in external program


Recommended Posts

Hello,

I'm totally blind, and use a variety of add-ons to fly the aircraft in Prepar3d or FSX.

I'm developing a Python script that reads out various aircraft instrumentation using text to speech. I would like to assign hotkeys inside the simulator to trigger speech events in my external python application. Is it possible to assign custom keys in fSUIPC that will update a custom offset that my application can monitor in order to read information?

For example, if I press Ctrl+Shift+A, an offset will fire that my app monitors that will then cause it to read the altitude? From looking at the advanced documentation, it looks like this should be possible. Just not sure which offsets I can use and how I could set this up.

Any pointers would be appreciated.

I can already read altitude, etc. from the simulator. I just want a way to trigger this from inside the sim. I'm tried to assign system-wide hotkeys from my application, but this hasn't been all that reliable.

 

 

 

 

Link to comment
Share on other sites

1 hour ago, Jason Fayre said:

Is it possible to assign custom keys in fSUIPC that will update a custom offset that my application can monitor in order to read information?

Yes. There is a range of three user offsets, from 66C0 to 66FF (64 bytes altogether). There are special FSUIPC controls you can assign.to any keypress or joystick device button

If 64 different actions are enough then you can use the Offset Byte Set contro, with the chosen offset aspecified and a parater on 1 or 0 as needed to turn something on or on.

It it is to trigger an action only, like playing a sound, then maybe Offset Byte ToggleBits would be better. This just toggles the specified bit 9or more, bits) in the offset specified,. you'd use parater 1 for bit 0, 2 for bit 1, 2 for bit 2, up to 128 for bit 7. This gives you up to 512 different actions (8 x 64), but I doubt you'd find enough buttons or keypresses to handle all those.

1 hour ago, Jason Fayre said:

For example, if I press Ctrl+Shift+A, an offset will fire that my app monitors that will then cause it to read the altitude?

Sounds good. Your "app" would need to handle a "toggle" of a bit differently to a Set (goes non-zero) or Clear (goes zero) change. Sounds to me as if you need to use Toggle commands.

1 hour ago, Jason Fayre said:

Just not sure which offsets I can use and how I could set this up.

The offsets are as I've said, 66C0 to 66FF -- 64 bytes. Setting up is just by assignment. 

Let us know if you need more help with setting this up.

Pete

 

Link to comment
Share on other sites

Hi,

Sorry, but I do think I need a bit more here. 

Can you write me a quick example of how I would format this in the ini file for a keyboard hotkey?

I was thinking that I would flip the bit on using FSUIPC after pressing the key, then use my external program to flip it off again once the info has been read.

In the dictionary of offsets that I'm pulling from FSUIPC, would this be a binary value?

Also, would anyone who uses my app need to have a registered FSUIPC? I'm guessing so.

In my script, I'm using pyuipc from the SDK.

 

 

 

Link to comment
Share on other sites

15 hours ago, Jason Fayre said:

Can you write me a quick example of how I would format this in the ini file for a keyboard hotkey?

I was thinking that I would flip the bit on using FSUIPC after pressing the key, then use my external program to flip it off again once the info has been read.

Well, It would actually be a lot easier to do in the Options for Key assignments, but perhaps editing files is easier for you?  So, here's an example:

64=90,24,x0D0066C0,x01     -{tab+Z: Press=offset byte setbits, offset 66C0 }-

Here 64 is just the entry nmuber in the list,
90 is the Key Code for Z,
24 is the sum of the two "shift code" values for  "Press" and  "Tab"
x0D0066C0 is the hexadecimal representation of 0D00 is the top part, for the control "Offset byte setbits"
and the lower part, 66C0 is the offset being changed.
01 is the parameter giving the bit (or several bits -- it's a hexadecimal value too) to be set.

15 hours ago, Jason Fayre said:

In the dictionary of offsets that I'm pulling from FSUIPC, would this be a binary value?

Sorry, I don't understand you mean here by "this". If you mean something you read from an offset then all vlaues are binary, whether code, strings or numbers. It's how their interpreted that matters.

15 hours ago, Jason Fayre said:

Also, would anyone who uses my app need to have a registered FSUIPC? I'm guessing so.

An application written to interface to FSUIPC using the mthods defined in the SDK do not need to be talking with a registered version. You'd need a registered version to assign the keys though. The keys section of the INI file won't be used otherwise. You'd need another program to detect the keys and set the offset. 

So to that extent you might as well have the program which is reading the altitude simply act on the keypresses itself. Why have FSUIPC detect the keypresses?

Pete

 

Edited by John Dowson
offset typos corrected
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.