Jump to content
The simFlight Network Forums

Help with Controls - testing with SET_EXTERNAL_POWER


DaveSCUSA

Recommended Posts

I am still struggling with getting events to work with now the Cessna Logitude.

I have attached a file with the pertinant information. The control I'm trying to get to work is the SET_EXTERNAL_POWER by pressing a key on my USB device. I'm using this key to debug my procedures.

The attached file shows the Log from two methods to turn the Cessna Longitude External Power switch on and off. The first entries in the Log are turning the External Power on and off using the virtual cockpit button resulting in  24829 *** EVENT: Cntrl= 67091 (0x00010613), Param1= 1 (0x00000001), Param2= 1 (0x00000001) SET_EXTERNAL_POWER. This works.

The second entries show the Log using the USB key resulting in the entry 34610 *** EVENT: Cntrl= 67091 (0x00010613), Param= 1 (0x00000001) SET_EXTERNAL_POWER. This did not work.

Included in the file are the entries in the profile for the key and the preset entry for the key.

Not sure why the SET_EXTERNAL_POWER control is not working and why there are two SET_EXTERNAL_POWER entries in the keypress logging. Would you help please?

I will incude the Log file.

Thanks

External Power Log Results.txt FSUIPC7.log

Link to comment
Share on other sites

5 hours ago, DaveSCUSA said:

Not sure why the SET_EXTERNAL_POWER control is not working

I have no experience with the Longitude, but it seems from the log file entry for the VC button that works you need two parameters both equal to 1 to turn the ext power on.
The USB key function that doesn't work seems to be using parameter values of  0 and 1 (which I think is the reason for the two entries), which turns the ext power off.

The SDK shows this:
image.thumb.png.2effc3e82dbc64c9f1572c554b9f00f7.png

So, for example I found:
ipc.execCalcCode(" 1 1 (>K:2:SET_EXTERNAL_POWER) ")  will turn the external power on, and

ipc.execCalcCode(" 0 1 (>K:2:SET_EXTERNAL_POWER) ")  will turn the external power off, where

the red 1 is the circuit index value (based on the systems.cfg file entry) and the green 1 and 0 are the On & Off data values.

However, I subsequently noticed there is an existing FSUIPC7 Preset called LONGITUDE TOGGLE EXTERNAL POWER SWITCH -- why not just assign a key to that (with no repeats)?

Also, be aware that not all sim parking places/gates have external power available.

Al

  • Like 1
Link to comment
Share on other sites

Some MSFS events now take two parameters, such as Set External Power. You cannot directly assign to such events via the FSUIPC UI as this only supports one parameter for each event.
To use such events, you need to define a preset as explained by @ark1320. Otherwise, also as mentioned by @ark1320, if a toggle control is sufficient you can also use that, maybe with an offset condition on the current state of the external power (if available).

II need to update the FSUIPC7 UI to either be able to handle events with two parameters (preferred), or to at least make it known to the user somehow which events take two parameters so that they can consider defining a preset for such events.

John

Link to comment
Share on other sites

Thank you Al and John for your time. Didn't expect an answer so quickly. 

Just to make sure I looked at everything, I did a quick look on the events using SPAD.NeXt. It showed Input Event B:ELECTRICAL_ExternalPower_1 (not sure why the FSUIPC7.log didn't show it) is used.

I didn't pick up the preset as I extracted the presets from Mobiflight to myevents.txt to reduce the number of entries. My bad, I missed the preset.

It's a shame that presets can't manipulate Input Events. Perhaps I need to use Lua. 

Is there a technique to turn an on/off Input Event to a toggle event?

Thank you both.

Link to comment
Share on other sites

2 minutes ago, DaveSCUSA said:

I did a quick look on the events using SPAD.NeXt. It showed Input Event B:ELECTRICAL_ExternalPower_1 (not sure why the FSUIPC7.log didn't show it) is used.

If that B-var is listed when you list Input Events, then you can try assigning to that. If it is not listed as an Input Event, it is a b-var that is not yet mapped to an external input event and can't be used.
I have noticed that some input events don't seem to be logged when used. I am not sure why this is at the moment - it is on my list to investigate and report to Asobo. If its listed as an Input Event (in FSUIPC) but not logged when the button is triggered, you can still try assigning to it.

6 minutes ago, DaveSCUSA said:

Is there a technique to turn an on/off Input Event to a toggle event?

There are two ways to do this:
1. Overload your button/key with two assignments, one to turn off and the other to turn on. Then use an offset condition on an offset that holds the current state of the external power switch.
2. Add the Input Event to a spare/free FSUIPC offset (as an unsigned byte) - see Advanced User guide (page 52), and then use the Offset Byte Togglebits control on that offset with a parameter of x1.

Link to comment
Share on other sites

Thank you for the hint to use x0D00zzzz Offset Byte Togglebits. Thank you but I'm confused.

I use an offset of an LVar to determine the state of the switch. E.g. 

42=L:Elect_Ext_Pwr=UB0x66DB

C700s_New_Ext_Pwr#(L:Elect_Ext_Pwr) if{ (>K:TOGGLE_EXTERNAL_POWER) 0 (>L:Elect_Ext_Pwr) }els{ (>K:TOGGLE_EXTERNAL_POWER) 1 (>L:Elect_Ext_Pwr) }

86=B66DB<1 N53,14,PC700s_New_Ext_Pwr,0                                 -{Preset Control}- 
88=B66DB<1 N53,14,IELECTRICAL_ExternalPower_1,1.000000       -{Input Event}-
90=B66DB>0 N53,14,PC700s_New_Ext_Pwr,0                                 -{Preset Control}-
92=B66DB>0 N53,14,IELECTRICAL_ExternalPower_1,0.000000       -{Input Event}-

Sometimes it doesn't work based, I believe, on the internal sequence and timing. I have seen in the log:

    34329 KEYDOWN: VK=53, Waiting=0, Repeat=N, lParam=0 (0x0), Shifts=6
    34329 .. This key is programmed in FSUIPC7 'Keys' options
    34594 EV_KEYDOWN received: 0x35 (5): repeat set (rate=250/100)
    34594 KEYDOWN: VK=53, Waiting=0, Repeat=Y, lParam=1073741824 (0x40000000), Shifts=6
    34594 .. This key is programmed in FSUIPC7 'Keys' options
    34610 *** EVENT: Cntrl= 67091 (0x00010613), Param= 0 (0x00000000) SET_EXTERNAL_POWER
    34610 *** EVENT: Cntrl= 67091 (0x00010613), Param= 1 (0x00000001) SET_EXTERNAL_POWER

For the above use of the button, the documentation of Offset Byte Togglebits that I found is:

x0D00zzzz Offset Byte Togglebits (offset = zzzz), hexadecimal, and

[LvarOffsets.B747]

1=L:XMLVAR_YokeHidden1=UB0xA000

Once an lvar has been added to an offset, you can use the offset for the lvar value as you would any other offset. You can also update the lvar by updating the offset value, using, for example, one of the FSUIPC Offset Controls (see page 35), such as Offset Word Set, or Offset Byte Togglebits. Make sure that the control that you use matches the size of the offset defined to hold the value. So, taking my previous example using the lvar XMLVAR_YokeHidden1, to assign a button/switch to control this lvar via the offset I have assigned (A000), I would assign to the control Offset Byte Togglebits, giving A000 as the offset and 1 (or x1) as the parameter.

Due to my lack of expreience, I have difficulty understanding how to use the Offset Byte Togglebits and the offsets. I thought the above would suffice for the Mom switch.

Could you please provide specific code that allows the above switch to work. It is problematic when there is an Input Event in play. Presets can't update Input Events and Presets can't update offsets. A dilemma. 

 

Link to comment
Share on other sites

@DaveSCUSA Can you tell me which Longitude you are using and I can see if I can get hold of this and take a look. I thought this was an Asobo aircraft but I only see the Citation CJ4, which has no Input Event as ELECTRICAL_ExternalPower_1.

Looking at your log extract, your keypress is turning the external power off and then on, so it looks like it is being triggered twice. Have you tried just using the Input Event (without the preset), and also just using the preset (without the Input Event)? If not, please try this. Usually, but not always, triggering the Input Event should be sufficient.

 

Link to comment
Share on other sites

 

3 hours ago, John Dowson said:

@DaveSCUSA Can you tell me which Longitude you are using and I can see if I can get hold of this and take a look. 

Thank you. Your answer doesn't have to be specific to an aircraft, however, the aircraft is the Cessna Longitude Citation.  

3 hours ago, John Dowson said:

@DaveSCUSA 

Looking at your log extract, your keypress is turning the external power off and then on, so it looks like it is being triggered twice. Have you tried just using the Input Event.

The switch I'm using is a single press button providing keypresses. I have tried 3 options: 1. Preset only, 2. Preset and Input Event, and 3. Input Event only. The only option that worked was #3 without the offset modifier.

My problem, is I want first press on and second press off. The example in my post (without the preset) works to turn the event on but not off.

In addition, I am trying to use the offset modifier technique to use a rocker switch (as on the Alpha and Bravo) with a simconnect toggle event. Push top on, push bottom off.

Link to comment
Share on other sites

5 minutes ago, DaveSCUSA said:

Your answer doesn't have to be specific to an aircraft, however, the aircraft is the Cessna Longitude Citation. 

But such controls ARE aircraft specific. I still don't know which aircraft you are using - is it this one: https://flightsim.to/file/50716/cessna-citation-longitude/416279

8 minutes ago, DaveSCUSA said:

The switch I'm using is a single press button providing keypresses. I have tried 3 options: 1. Preset only, 2. Preset and Input Event, and 3. Input Event only. The only option that worked was #3 without the offset modifier.

My problem, is I want first press on and second press off. The example in my post (without the preset) works to turn the event on but not off.

So, to be clear, the Input Event works on its own (without the offset condition) works to turn on, but not off? Not sure why the offset condition isn't working - try monitoring the offset value to see if that is correct. 

If you assign two key presses, one for off and the other for on, using input events only, does that work? And if so, do you see the value of the Input Event in the offset change when you do this? If so, it should be possible on one key with an offset condition.

Link to comment
Share on other sites

18 minutes ago, John Dowson said:

I still don't know which aircraft you are using - is it this one: https://flightsim.to/file/50716/cessna-citation-longitude/416279

The Lonfitude should be in the premium deluxe version, which I have, but I don't see this in my aircraft selection - and I even have the WT enhancement for this aircraft installed...strange...

Link to comment
Share on other sites

1 hour ago, John Dowson said:

The Lonfitude should be in the premium deluxe version, which I have, but I don't see this in my aircraft selection - and I even have the WT enhancement for this aircraft installed...strange...

It is strange as I have the aircraft in 3 separate instances of MSFS on 3 PCs. The default is in the Official folder with all other aircraft (with at least 8 liveries) and a mod (correcting default flight and control characteristics) in the Community folder.

Link to comment
Share on other sites

1 minute ago, DaveSCUSA said:

It is strange as I have the aircraft in 3 separate instances of MSFS on 3 PCs. The default is in the Official folder with all other aircraft (with at least 8 liveries) and a mod (correcting default flight and control characteristics) in the Community folder.

Yes, I can see it in my MSFS official folder, with 9 additional livery folders. It just doesn't appear in the MSFS aircraft selection. I did have the WT mod installed, so uninstalled that, and that other  N75RA mod I linked to above.
Maybe its the xbox liveries I have installed - will try removing those...

Link to comment
Share on other sites

Looking in the MSFS debug window, it looks like the longitude is registered but not mounted, but the 6 livery folders are refistered AND mounted. I did have the Test Pilot livery installed and that was registered but not mounted as well - I removed that and no change.

Anyway, this is an issue on mu side that I will look into.

For your issue, please try what I suggested, i.e. monitor the offset holding the input event value, initial use two keys assigned to the input event (only) to switch on/off, and see if that works and the offset value changes. If it does, then you should be able to use one key with the assignments overloaded and with an offset condition.

Also maybe try just one key assigned to the MF preset LONGITUDE_TOGGLE_EXTERNAL_POWER_SWITCH, or to the FS control TOGGLE_EXTERNAL_POWER with a parameter of 1 (which is what that preset uses).

Link to comment
Share on other sites

It does work with two buttons. The toggles don't work at all. I monitor the offsets and they are set at least on the on state, value 1. But they aren't always reset in the preset as shown above.

As you know I'm setting the offset using LVars changed in the preset. Is there a way to set the offset and the input event in the profile [Keys] area? Is the ,bool with LVar mandatory in the preset?

Could you provide me an example?

It seems keypresses have less functionality than buttons or I'd try compound presses.

Perhaps I'll just use Lua. In the past, I made the Lua too complicated. I do have an Lua that enters 0 in the offsets used and creates the LVars.

Link to comment
Share on other sites

1 minute ago, DaveSCUSA said:

It does work with two buttons. The toggles don't work at all.

If it works with two buttons, foes the offset holding the Input Event change value? If so, you can use offset conditions.

2 minutes ago, DaveSCUSA said:

As you know I'm setting the offset using LVars changed in the preset.

No, I didn't know this and find this confusing. I thought you were using the Input Event only, not lvars. Can you please show me the assignments that work, and/or explain what you mean.

4 minutes ago, DaveSCUSA said:

Is there a way to set the offset and the input event in the profile [Keys] area?

Could you provide me an example?

Not sure what you mean here, please explain. I am confused about your assignments and what is working. Why are you talking about offsets when the assignment is using input events (or so I thought)?
If the input event works, you can try just using the input event offset and write to that.

7 minutes ago, DaveSCUSA said:

It seems keypresses have less functionality than buttons or I'd try compound presses.

There are differences - compound functionality relates to the state of one button (or button flag) when another is pressed. For key presses, this just doesn't make sense. For key presses, you use modifier keys, not other conditional keys, hence the difference. Offset conditions are the same for keys as buttons.

Link to comment
Share on other sites

Thanks, again. The reason I use LVars, is using presets with most keypresses. The difference comes with the requirement to use an input event for the function which can't be set in the preset. Seems like only button/keys and Lua can provide a param to an input event while one cannot change an offset with the buttons/keypresses in a profile.

Would you please show the best code to set an Input Event on and off using a mom button. I can handle normal A:, K:, and L: vars. Step A code, Step B code ...... Step x code.

Link to comment
Share on other sites

28 minutes ago, DaveSCUSA said:

The reason I use LVars, is using presets with most keypresses.

Sorry, what does this mean?

28 minutes ago, DaveSCUSA said:

The difference comes with the requirement to use an input event for the function which can't be set in the preset.

But you need to check fist if the input event is sufficient. Normally, a properly implemented input event will do several things, such as triggering events (k-vars) and updating lvars, so you shouldn't need to do anything else but trigger the input event. But, as I keep saying, this depends on how things are implemented. You need to test.

28 minutes ago, DaveSCUSA said:

Seems like only button/keys and Lua can provide a param to an input event while one cannot change an offset with the buttons/keypresses in a profile.

This doesn't make sense...of course you can change an offset with/on a button or keypress, using the provided offset controls. You can also do that in a profile - whatever you can do in general assignments, you can do in a profile.

28 minutes ago, DaveSCUSA said:

Would you please show the best code to set an Input Event on and off using a mom button.

What is a 'mom button'?. If you mean a standard (momentary button), then I just call that a button (i.e. a standard button) - the other types are sticky buttons (i.e. stay in when pressed, and release when pressed again). If thats the case, I have already shown you - use overloaded assignments and an offset condition. BUT, you need to test the offset that you a are using, which is why I have asked you to monitor the offset that holds the Input Event. Did you try this?

And input events have values, not off/on, although some may have a value of 1 for on and 0 for off. But input events seem to be like lvars - they are just a different type of variable that holds a value. To set/change this value, you just assign to the input event and specify the value as the parameter. 

 

Edited by John Dowson
corrected
Link to comment
Share on other sites

You also said: 

56 minutes ago, DaveSCUSA said:

It does work with two buttons.

I asked to see these assignments that work. Please show me them and we can go from there. If they are using Input Events, please log the offset holding the input event and see if that changes. If so, you can use one button and an offset condition on your two assignments. Otherwise, if an lvar changes, add that to an offset and use that for your offset condition.

If the input event  works on its own, you can also just write to the offset to change the value of the Input Event,

Link to comment
Share on other sites

Note also that some devices send a press on the first button press, and a release on the second button press, acting like 'sticky' buttons. For such devices, you need to assign on the press and release. You seem to be using some sort of button-box that sends key presses, no? If so, check it is sending the same key presses each time you press, and if the second press is a release, you need to assign to that as well.

Otherwise, follow my previous posts and respond to them. And show me your assignments and log files so that I can see what is happening - these are needed as otherwise I cannot understand what you are trying to tell me.

Finishing now for the day. I will review again tomorrow - and see if I can get access to the Longitude to take a look.

John

Link to comment
Share on other sites

3 hours ago, John Dowson said:

Also maybe try just one key assigned to the MF preset LONGITUDE_TOGGLE_EXTERNAL_POWER_SWITCH, or to the FS control TOGGLE_EXTERNAL_POWER with a parameter of 1 (which is what that preset uses).

If it helps the investigation here, I tried both of the above (assigned a different key to each one) and they both work to toggle the Longitude's external power on and off.

Al

Link to comment
Share on other sites

7 minutes ago, ark1320 said:
3 hours ago, John Dowson said:

Also maybe try just one key assigned to the MF preset LONGITUDE_TOGGLE_EXTERNAL_POWER_SWITCH, or to the FS control TOGGLE_EXTERNAL_POWER with a parameter of 1 (which is what that preset uses).

If it helps the investigation here, I tried both of the above (assigned a different key to each one) and they both work to toggle the Longitude's external power on and off

Thanks Al - I don't know why the OP just doesn't use those instead of messing around with input events and lvars. The easiest way is usually the better way...maybe @DaveSCUSA could explain why he can't use either of those, as he just seems to want to toggle on a keypress.

Link to comment
Share on other sites

Because I tested and the TOGGLE_EXTERNAL_POWER didn't work (perhaps due to the index as shown above). I didn't know about the LONGITUDE toggle. I try them again. 

If one wants to use yokes, throttles, etc., and buttons, and key presses instead of virtual cockpit, MSFS and aircraft developers make it difficult. They are not consistent with gauges and switches. Very confusing for those of us that just want to fly. 

The most difficulty is communicating with the jargon and terms you all share as opposed to us that are confused. I will not be at my Sim until Thursday.

If someone would just follow my request, we can forget the external power and the toggle.

The request again is:

Can you show the code needed to use an offset to turn an Input Event on and off based on the state of the offset. Presume I know how to define an offset either in a profile or my offsets.

 

Link to comment
Share on other sites

Did some experimenting to see if I could figure out how assigning an input event to an offset worked ...

I assigned the input event ELECTRICAL_ExternalPower_1 as an unsigned byte to an available offset A080 in the general section ( I don't fly the Longitude so I don't have a specific profile for it ) of my FSUIPC7.ini file as shown below:

[InputEventOffsets]
1=ELECTRICAL_ExternalPower_1=UB0xA080

Then in the FSUJIPC7 key assignments window I assigned the U key to toggle the bit(s) in that offset as shown below:

image.png.4f33d3f7129b162e67a79645f2e3ec90.png

Somewhat to my surprise this worked -- after restarting FSUIPC7 the U key did toggle the Longitude's external power on and off.

I defined the offset as a byte because I thought the input event goes between 0 and 1. Although this worked, there are couple of things I'm not sure about:

- I found the Parameter value of 1 is required, I assume because this external power function seems to need a circuit index of 1. Or is the Parameter being used in some other way? Maybe I missed it, but I didn't see anything in the manual that explained how the Parameter value is used in an Offset operation like this.

- I think of the input event as toggling between 0 and 1. But if byte A080 holds a decimal value of 1, which would be 00000001 binary, then toggling those bits with the offset toggle bits operation would give a value of 11111110 binary, not 00000000 = 0. So not sure how this all works.

Al

  • Like 1
Link to comment
Share on other sites

3 hours ago, ark1320 said:

- I found the Parameter value of 1 is required, I assume because this external power function seems to need a circuit index of 1. Or is the Parameter being used in some other way? Maybe I missed it, but I didn't see anything in the manual that explained how the Parameter value is used in an Offset operation like this.

The parameter is the bit (in the byte) to toggle. x1 is but 0 (2^0). If it was bit 1 you wanted to toggle, you would use x2 (2^1=2), bit 2 would be x4, etc. And you toggle multiple bits by summing. So x3 would toggle bits 0 and 1. Basically its the mask of bits to toggle.

3 hours ago, ark1320 said:

I think of the input event as toggling between 0 and 1. But if byte A080 holds a decimal value of 1, which would be 00000001 binary, then toggling those bits with the offset toggle bits operation would give a value of 11111110 binary, not 00000000 = 0. So not sure how this all works.

A byte cannot hold a decimal value - you would need 4-bytes for that (a float). FSUIPC does the conversion of the original decimal value of the Input Event using the modifier you specify in the line where you add the input event to an offset.

10 hours ago, DaveSCUSA said:

Because I tested and the TOGGLE_EXTERNAL_POWER didn't work (perhaps due to the index as shown above).

No, you didn't try this - that was SET EXTERNAL POWER, which requires two parameters. The toggle control only needs one.

10 hours ago, DaveSCUSA said:

Can you show the code needed to use an offset to turn an Input Event on and off based on the state of the offset.

You add it to an offset and toggle that offset, as Al showed in the previous post. As its a toggle control, you don't need to gave a condition on this. If you did, you would just add an offset condition as explained in the Advanced User guide.

John

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.