Jump to content
The simFlight Network Forums

event.control usage


Recommended Posts

Hi Pete,

Is there any reason why I would have difficulty trapping a flap inc/dec event using Lua controls and calling a simple Lua function to display the flap activation on the screen. I'm using

event.control(65758,"flaps_inc")

event.control(65759,"flaps_dec")

below the function definition as, for example,

function flaps_inc(controlnum,param)

ipc.display("Flaps Increment",2)

end

This seems to work fine with other controls, pitot heat for example,

event.control(65858,"pitot_on")

and a similar display function.

I have set up the flap control in FSUIPC using an axis to give the two commands for a fixed range of values ( inc or dec) and they work fine, the controls are shown as logged and they are activated but no on-screen Lua display. The standard FSX key presses are still defined.

Is there some basic error here?

Many thanks for any help,

Regards

Link to comment
Share on other sites

Is there any reason why I would have difficulty trapping a flap inc/dec event using Lua controls and calling a simple Lua function to display the flap activation on the screen.

Not that I know of. This works for me:

function flaps_inc(controlnum, param)
   ipc.display("Flaps increment", 2)
end

function flaps_dec(controlnum, param)
   ipc.display("Flaps decrement", 2)
end

event.control(65758, "flaps_inc")
event.control(65759, "flaps_dec")

Does yours look like that?

I have set up the flap control in FSUIPC using an axis to give the two commands for a fixed range of values ( inc or dec) and they work fine, the controls are shown as logged and they are activated but no on-screen Lua display. The standard FSX key presses are still defined.

Ah. I've not tried is via any axis assignment. I'll test that too. Did you test with the normal keyboard assignments? It works okay with those here, and with keys assigned in FSUIPC. I'll need to attach a joystick to test buttons and axes ...

... It works too here for button and axis assignments. I am using a later interim update than the one in the Updates announcement, but I don't think that will be any different.

Sorry, I don't know what you have different there. You have checked that the Lua program is loading and not being logged with some error, haven't you? Try mine.

Regards

Pete

Link to comment
Share on other sites

Hi Pete,

Many thanks for the prompt reply and your suggestions.

I have checked the log file and the lua program installs ok. I have checked that the flaps also activate on the standard key presses but no on-screen Lua display results.

However, as in your own testing possibly, I have tried the same code on a native FSX model and it works fine so it look like the issue is aircraft specific. I also tried an offset based event trap using 0x0BDC and that works fine as well in the FSX aircraft but not in the P47 that I am coding for.

So, in all cases the FSUIPC log catches the activity as it's being implemented, it's just that the Lua function for the flaps is not being activated in the P47. It's strange that the other switches that I've tried (eg pitot) seem to work ok in the P47.

Thanks again for the help,

Best Regards.

Link to comment
Share on other sites

So, in all cases the FSUIPC log catches the activity as it's being implemented, it's just that the Lua function for the flaps is not being activated in the P47. It's strange that the other switches that I've tried (eg pitot) seem to work ok in the P47.

The Lua "event.control" check is performed in the exact same place, where Events are intercepted, as the Events are logging in the FSUIPC4 log file. Are you saying that the log shows the event but it isn't triggering the Lua call? (I'm talking about the event logging which gives lines starting "*** EVENT: Cntrl= ..."). If so I don't understand how that could happen as the two parts are inseparable in the code. The Lua call occurs in the next line of code after the Log entry is written.

If the log entry is not occurring, then your aircraft is intercepting the event and swallowing it at an even higher priority than FSUIPC does. I've not seen that before -- the FSUIPC priority is highest. In order to do that it evidently must get in the chain before FSUIPC (naturally, I suppose as Gauges load later). There's really not much i could do about that.

Regards

Pete

Link to comment
Share on other sites

Hi Pete,

Following on from your suggestion, I've now done the following to check out the event logging in more detail:

1) I set a button to trigger a flaps inc/dec event followed by the pitot switch in rapid succession

ipc.control(65758)

ipc.sleep(10)

ipc.control(65759)

ipc.sleep(10)

ipc.control(65858)

and then activated FSUIPC logging to Buttons/Keys and Events.

2) In the P47, does the following suggest that the pitot switch is triggered but not the flaps? By the way, I notice that there is a continuous stream of other data in this case.

183953 FS Control Sent: Ctrl=65758, Param=0

183969 FS Control Sent: Ctrl=65759, Param=0

184000 FS Control Sent: Ctrl=65858, Param=0

184000 *** EVENT: Cntrl= 65858 (0x00010142), Param= 0 (0x00000000) PITOT_HEAT_TOGGLE

3) In another aircraft, with the same code, it looks like all of the events are registered? Also, there is no continuous stream of events in this case.

358047 FS Control Sent: Ctrl=65758, Param=0

358047 *** EVENT: Cntrl= 65758 (0x000100de), Param= 0 (0x00000000) FLAPS_INCR

358078 FS Control Sent: Ctrl=65759, Param=0

358078 *** EVENT: Cntrl= 65759 (0x000100df), Param= 0 (0x00000000) FLAPS_DECR

358125 FS Control Sent: Ctrl=65858, Param=0

358125 *** EVENT: Cntrl= 65858 (0x00010142), Param= 0 (0x00000000) PITOT_HEAT_TOGGLE

361750 FS Control Sent: Ctrl=65752, Param=32767

Presumably the Lua code is not triggered in the case of the P47 because the FS control does not trigger the *** Event in this case?

What happens in the process between the FS Control Sent action occurring and the event subsequently being triggered?

Many thanks again for all your help, it's only a small issue but it's useful I guess as it helps the learning process!

Regards and best wishes,

Link to comment
Share on other sites

2) In the P47, does the following suggest that the pitot switch is triggered but not the flaps?

No, only that the two flaps controls aren't going through the SimConnect chain at all. they are being "swallowed" before they get to FSUIPC's logging. I explained that this is what I thought must be happening if you recall.

FSUIPC can do the same sort of thing -- steal controls before anything lower in the chain can get them. This is how it can re-map some of the axis controls, for instance.

Your stream of other events happens with some aircraft gauges -- usually they are repetitive and very very wasteful of FS performance. I don't know why some aircraft designers do such things. I'd avoid such aircraft myself.

Presumably the Lua code is not triggered in the case of the P47 because the FS control does not trigger the *** Event in this case?

Yes, as I explained in a previous message which it now seems you must have missed?

What happens in the process between the FS Control Sent action occurring and the event subsequently being triggered?

Your aircraft code receives it at a high, maskable, SimConnect level and prevents it being passed down to FS code. It must be simulating its own flaps, not wanting FS code to interfere.

Regards

Pete

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.