Jump to content
The simFlight Network Forums
chumley

Single key - multiple functions

Recommended Posts

I am doing some work on assigning PMDG NGX functions to keystrokes using the information PMDG has provided in the SDK.

I have been able to assign the 'Ground Power' to a key and it switches on when I press the key. I would like to be able to have a second press of the same key to switch it off.

I have spent some time trying to achieve this goal but thus far to no avail.

Is it possible to do this and if so can someone point me in the direction of the way to achieve it.

I would consider using a button if that is the only alternative but buttons are scarce whereas keys are many.

Thanks

Share this post


Link to post
Share on other sites
10 hours ago, chumley said:

I have been able to assign the 'Ground Power' to a key and it switches on when I press the key. I would like to be able to have a second press of the same key to switch it off.

I have spent some time trying to achieve this goal but thus far to no avail.

You'd need to use a user offset (anything between 66C0 and 66FF) to remember the state and use that as a condition on the action. This involves editing the INI file [Keys] section. For the chosenn key you'd use three lines:

1. one line which uses an FSUIPC Offset byte togglebits control to change the byte from/to zero
2. a line with an offset condition testing for zero, and doing one action
3. a line with an offset condition testing for non-zero, and doing the other action

Offset conditionals are actually described in the Buttons section of the Advanced User's guide, with a reference to itfrom the Keys section.

10 hours ago, chumley said:

I would consider using a button if that is the only alternative but buttons are scarce whereas keys are many.

The FSUIPC Advanced User documentation details how overcome this, and do multiple actions, with buttons and switches, making actions conditional on offset values or other buttons being pressed. There are also flags which can be used to remember the state of one button or switch and using it as the condition on another, so they don't need to be pressed simultaneously. Folks have done a lot with the normal numbers of buttons on joystick type devices.

Pete

 

 

Share this post


Link to post
Share on other sites

Thanks Pete.

I have had a look at the FSUIPC Advanced User Documentation and it is all gobbledygook to me. 

I think I will stick to flying the simulator 'as is' and pretend the mouse pointer is actually my finger.
 

Share this post


Link to post
Share on other sites

Hi Pete

After a period of reflection I really do want to be able to control more of my Sim using a combination of keys and buttons so am asking of how the FSUIPC.ini file can be amended to make the example below work. Once I have a framework to work with I will be able to make similar functions happen.

So my example is I want to use the Joystick 1 Button 1 to action the taxi Light switch on the PMDG NGX panel which according to PMDG is 69749 (69632+117).

After using the GUI to create the first action I have:

4=P1,1,C69749,1

Note: (0-3 inc in the numbering sequence are taken up with viewing option using the hat switch on the yoke)

I have had a look at the various documents but cannot quite come to grips with the process. 

I know from previous comments by you that two more lines will allow a conditional test to be applied and presumably from that a second press of the P1,1 will switch the lights off.

How would those two conditional lines be coded?

I have tried this but it doesn't work:

5=B66CO=0 P1,1,C69749,1
6=B66CO=0 P1,1,C69749,0


Thanks

Share this post


Link to post
Share on other sites
17 minutes ago, chumley said:

After using the GUI to create the first action I have:

4=P1,1,C69749,1

Note: (0-3 inc in the numbering sequence are taken up with viewing option using the hat switch on the yoke)

I have had a look at the various documents but cannot quite come to grips with the process. 

I know from previous comments by you that two more lines will allow a conditional test to be applied and presumably from that a second press of the P1,1 will switch the lights off.

How would those two conditional lines be coded?

I have tried this but it doesn't work:

5=B66CO=0 P1,1,C69749,1
6=B66CO=0 P1,1,C69749,0

Well, three things wrong. I don't see that you followed my instructions which were:

1. one line which uses an FSUIPC Offset byte togglebits control to change the byte from/to zero
2. a line with an offset condition testing for zero, and doing one action
3. a line with an offset condition testing for non-zero, and doing the other action

There's no sign of the line 1 I suggested. That's best done first in the GUI.  Instead of assigning to the PMDG control there, assign to Offset byte togglebitsset the Offset field to 66C0, and the Parameter to 1.

You have a line testing something for zero, but not 66C0 -- you have 66CO (with a letter O). [The letters in the values here only go from A to F, representing 10 to 15].

Then you have the same condition again (B66CO=0) instead of B66C0=1.

NOTE, though, that there is another way to implement a toggle action as in this case -- the offset way is more general and can cope with any number of different actions, not just two -- but the Flag method is probably best for such simple toggles. So i'll describe that a bit too (it is covered in more detail, with examples, in the Advanced User's guide -- with very advanced applications in a Appendix).

Every possible button on every possible joystick ID (so 16 x 32 or 512 buttons) has a "flag" -- an internal marker which is either "on" (1) or "off" (0).  These can be explicitly set or cleared or toggled (changed) by FSUIPC controls.

However, the Flag associated with each button is also toggled (changed) whenever that button, assuming it exists, is pressed. Therefore it changes with each press.

In your case we can simply add two (instead of three) lines, as follows:

4=CP(F-1,1)1,1,C69749,1
5=CP(F+1,1)1,1,C69749,0

Please, by all means just blindly put this into the INI file and test it, but also see if you can understand it, and the earlier elucidations on offset conditions, because then you can apply these techniques in all sorts of ways to expand your use of buttons and FSUIPC's facilities.

Pete

 

Share this post


Link to post
Share on other sites

Thanks again Pete.

I have put your code in the FSUIPC.ini and it works just fine. I will work through it in detail to get across the structure using the various manuals as you suggest as i can see quite a bit to gain particularly if I progress to putting together a few switch panels with the help of a friend.

I also delved a little further into your original suggestion and have come up with the following coding in the FSUIPC.ini which has a problem in that it toggles the taxi light on but doesn't toggle it off.

4=P1,0,Cx0D000042,x01     -{offset byte togglebits, offset 0042}-
5=B66C0=0 P1,0,C69749,1     -{Custom control: <69749>}-
6=B66C0=1 P1,0,C69749,0     -{Custom control: <69749>}-

I'm obviously missing the point somewhere.

I appreciate your help in this matter.

Thanks

Share this post


Link to post
Share on other sites
30 minutes ago, chumley said:

I also delved a little further into your original suggestion and have come up with the following coding in the FSUIPC.ini which has a problem in that it toggles the taxi light on but doesn't toggle it off.

4=P1,0,Cx0D000042,x01     -{offset byte togglebits, offset 0042}-
5=B66C0=0 P1,0,C69749,1     -{Custom control: <69749>}-
6=B66C0=1 P1,0,C69749,0     -{Custom control: <69749>}-

The reason it doesn't work is that this line

4=P1,0,Cx0D000042,x01     -{offset byte togglebits, offset 0042}-

is, as it clearly says, toggling bit 1 in offset 0042 (which is NOT a user offset, and in actually a character in the start-up flight name). You should have programmed it for offset 66C0, which is the offset you are testing in the next two lines and which is a user offset!

Change P1,0,Cx0D000042,x01 to P1,0,Cx0D0066C0,x01

Pete

 

Share this post


Link to post
Share on other sites

I used the GUI as you suggested to select the byte togglebits and in the Offset box I entered 66C0. After manually changing the .ini to correct the offset and returning to the GUI I now realise I should have entered an x before the 66C0.

Working as expected now. 

I now feel a bit more confident and motivated to move forward.

Once again many thanks for the help.

Share this post


Link to post
Share on other sites

Just a small further question.

I have just noticed that the toggle doesn't respond to the first button press but then activates on each press  thereafter.

Is this a normal situation?
 

Share this post


Link to post
Share on other sites
21 hours ago, chumley said:

I have just noticed that the toggle doesn't respond to the first button press but then activates on each press  thereafter.

Is this a normal situation?

It sounds like you have the switch already set in the position which control 69749 with parameter 0 is intended to set, so it can't do anything. Offset 66C0 will be 0 to start with so toggling it first sets it to 1. You can change that in any of three ways:

4=P1,0,Cx0D0066C0,x01     -{offset byte togglebits, offset 66C0}-
5=B66C0=1 P1,0,C69749,1     -{Custom control: <69749>}-
6=B66C0=0 P1,0,C69749,0     -{Custom control: <69749>}-

or

4=P1,0,Cx0D0066C0,x01     -{offset byte togglebits, offset 66C0}-
5=B66C0=0 P1,0,C69749,0     -{Custom control: <69749>}-
6=B66C0=1 P1,0,C69749,1     -{Custom control: <69749>}-

or

6=P1,0,Cx0D0066C0,x01     -{offset byte togglebits, offset 66C0}-
4=B66C0=0 P1,0,C69749,1     -{Custom control: <69749>}-
5=B66C0=1 P1,0,C69749,0     -{Custom control: <69749>}-


The first two should be obvious, the last makes use of the fact that the actions are executed in the line number (value before the = ) order. 

Do you see the logic in these?.

Pete

 

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

×

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.