Jump to content
Sign in to follow this  
Rocky

send_key_event

Recommended Posts

Guest bartels

E.g. this works for a new event:0 (>K:SLEW_TOGGLE)Only key "K" is accessed no "lockout" of other keys.But only if the gauge is "visible".Arne Bartels

Share this post


Link to post
Share on other sites

That's interesting. I saw those functions in fs9.h but didn't try to understand how they work yet. I am now working on a completely different way of solving this problem.Thanks for your help anyway !!Eric

Share this post


Link to post
Share on other sites
Guest _ak

this function can intercept events but it can't filter them.In other words you will able see event, but FS will see it too.I have checked assembly after return from callback. FS not verifyes return value.

Share this post


Link to post
Share on other sites

>That's interesting. I saw those functions in fs9.h but didn't>try to understand how they work yet. I am now working on a>completely different way of solving this problem.If you are building the model as well as programming the gauges, why not create your very own "spoilers" command variable using embedded XML code in the .mdl file?With this method, control of the "spoilers" is accessible only via a custom XML L:varible and may be controlled either by an XML gauge or a C gauge...


Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Share this post


Link to post
Share on other sites

This is also an interesting option, but unfortunately it is not possible here as I am not the designer of the model.Thanks for the info !!Eric

Share this post


Link to post
Share on other sites

Hello _ak,This function is very interesting for many purposes, but I can't use it, it crashes FS as soon as I use it. Here is the code I used:static int CatchKeyEvent(ID32 event, UINT32 evdata, PVOID userdata){ ... return 0;}and in my initialization function:...register_key_event_handler(CatchKeyEvent, NULL);...I can't find what is wrong here ?!?Thanks for any help !!Eric

Share this post


Link to post
Share on other sites
Guest zip

Hi Eric,the import functions in the gauge callback is not documented (imagine that), an my past experience with those is that it crashes, probably because this is something you need to "hook and pass", meaning, you can't just grab it - the previous handler needs to be called in the chain.One sure way to prevent FS from getting keys is by using a keyboard hook event using the SetWindowsHookEx API call. This grabs windows virtual keys (and associated scan codes for brake or make), and you get to select if you want the key to be passed on or not.This will not crash FS and can be quite efficient at filtering keys, and unlike DX, no issues preventing the key from being processed by another listener registered by the same handle (which you share with FS since the gauge file runs in the same handle space).I have not looked at how, or where FS stores keyboard mappings (registry, cfg file or other), but I'm pretty sure that if you just map CTRL-E, and prevent FS from seeing it by the above method, no-one will complain much, and if they try an autostart, I'd just kill the fuel flow in code which will also kill the autostart sequence (=, set the mixture axis to minimum). Oh, and all this help comes with a "free" panel my Mr. Marciano right?

Share this post


Link to post
Share on other sites

As I have already answered to this kind of suggestion, the problem with the solution you propose here is that I can catch CTRL-E key, but if the user has changed hs key assignment, it will not work. This is why I wanted to use the event handler function to catch the key related to the event, whatever it is.Regarding your last question, all the questions asked here are for my personal knowledge. This knowledge is globally used for both freeware and payware projects. Don't worry, I will release a new freeware version of my Airbus panels that will take advantage of all these things learned, the only question is WHEN. I'm still running after time...Eric

Share this post


Link to post
Share on other sites
Guest _ak

>This function is very interesting for many purposes, but I>can't use it, it crashes FS as soon as I use it. Here is the>code I used:>>static int CatchKeyEvent(ID32 event, UINT32 evdata, PVOID>userdata)>{> ...> return 0;>}Change it to

static int FSAPI CatchKeyEvent(ID32 event, UINT32 evdata, PVOID userdata)

Don't ask why MS forgot to write calling convention to sdk.

Share this post


Link to post
Share on other sites
Guest bartels

FSAPI missing is "business as usual" for FS SDKs. Didn't surprise me, I didn't have time to check for myself, but inserting "FSAPI" (defining the calling convention) was also my first thought.Arne Bartels

Share this post


Link to post
Share on other sites

I did add the FSAPI prefix before, but it was not working because of a compilation error (incompatible types). I have casted and now it works fine. So the final code is:static int FSAPI CatchKeyEvent(ID32 event, UINT32 evdata, PVOIDuserdata){ ... return 0;}and in my initialization function:...register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)CatchKeyEvent, NULL);...And this works fine !!Thanks for your help.Eric

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
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...