Jump to content
Sign in to follow this  
Guest _ak

Key Event Handlers

Recommended Posts

This will notify you whenever a key_event is triggered.void FSAPI EventHandler (ID32 event, UINT32 evdata, PVOID userdata){ if (event == KEY_SPOILERS_TOGGLE) { //user has toggled the spoilers }}In the gauge callback:register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler, 0);andunregister_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler,0);Hope it'll be as useful to you as it's been to us. :-)

Share this post


Link to post
Share on other sites
Guest Fabio Miguez

Hey all,Guess no one realizes the potential for this, or they already knew it? Or perhaps the number of C programmers has gone down :-hmmm

Share this post


Link to post
Share on other sites

>Hey all,>>Guess no one realizes the potential for this, or they already>knew it? Or perhaps the number of C programmers has gone down>:-hmmmWell, I found it interesting enough to print out and add to my "appendix" for the SDK... :)


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
Guest _ak

Bad thing that you can't filter events like in keyboard hooks

Share this post


Link to post
Share on other sites
Guest bartels

Had finally time to try this, yes pretty useful, as I need to remap several events in a new project. It does the same as ... ..in XML. Don't know to fetch the "evdata" equivalent in XML yet (M:..?)Arne BartelsP.S. and never forget the FSAPI in C! The definition in fs9gauges.h should look like this:typedef void FSAPI VGAUGE_KEY_EVENT_HANDLER (ID32 event, UINT32 evdata, PVOID userdata);typedef VGAUGE_KEY_EVENT_HANDLER *GAUGE_KEY_EVENT_HANDLER;

Share this post


Link to post
Share on other sites
Guest zip

This is great!While you can't filter it, you can probably undo it if you know what it was...

Share this post


Link to post
Share on other sites
Guest Skymed

I am still hoping one of you gurus comes up with a way to intercept a key input in XML so that it can actioned by XML but NOT actioned by the flightsim itself.I really want the starter to be activated by an external button on a joystick, which means(If I am correct) that the button or keyboard event MUST be assigned to the starter. Problem is the darned starter in FS9 always runs regardless of whether the engine has failed, the battery is off etc etc when it is assigned to a key or button, so by "grabbing" the input away from the computer and filtering it through an XML gauge, I can prevent this.Steve

Share this post


Link to post
Share on other sites
Guest SRS-103

>This will notify you whenever a key_event is triggered.>register_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler,>0);>and>unregister_key_event_handler((GAUGE_KEY_EVENT_HANDLER)EventHandler,>0);I think it is not absolutelly correct. I even gives you an event if the input focus is NOT on FS window. For example if you type something in a multisession chat window (or SB3, IvAp chat) then this event is triggered causing big troubles.I checked a solution where they used this to activate/deactivate the non-standard autopilot. It switched AP status and nearly killed me while I was chatting with the ATC.I checked the same with the default Cessna and there pressing "Z" key in the chat window does NOT affected AP status.I am just looking for the OFFICIAL and correct way to handle keyboard input.Gabor

Share this post


Link to post
Share on other sites
Guest bartels

There is none. Gauges are not supposed to read keypresses.However, there are ways to do it, e.g. using key event handlers, but that is NOT reading keypresses directly. With key event handlers you can fetch the key events, which are already interpreated keypresses. You might also use DIrectInput to read the keyboard "parallel" to FS, other ways might be also possible.Arne Bartels

Share this post


Link to post
Share on other sites
Guest wysspeter

Almost all payware FMC have a keyboard input button. If it is pressed every keypress goes to the gauge and not to the flightsim. How can they do that?I managed to read the keys with DirectX, but how can I prevent FS from reading the key too?

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

>P.S. and never forget the FSAPI in C! The definition in>fs9gauges.h should look like this:>typedef void FSAPI VGAUGE_KEY_EVENT_HANDLER (ID32 event,>UINT32 evdata, PVOID userdata);>typedef VGAUGE_KEY_EVENT_HANDLER *GAUGE_KEY_EVENT_HANDLER;Or more precisely:typedef void (*GAUGE_KEY_EVENT_HANDLER) (ID32 event, UINT32 evdata, PVOID userdata);Note that MS fixed the missing "void" from previous versions, although it was assumed by most compilers (at least theirs for sure).Patrick

Share this post


Link to post
Share on other sites
Guest Patrick_Waugh

>I am still hoping one of you gurus comes up with a way to>intercept a key input in XML so that it can actioned by XML>but NOT actioned by the flightsim itself.>>I really want the starter to be activated by an external>button on a joystick, which means(If I am correct) that the>button or keyboard event MUST be assigned to the starter.>Problem is the darned starter in FS9 always runs regardless of>whether the engine has failed, the battery is off etc etc when>it is assigned to a key or button, so by "grabbing" the input>away from the computer and filtering it through an XML gauge,>I can prevent this.>>SteveStarters have been fixed in FS X.

Share this post


Link to post
Share on other sites
Guest Skymed

2 years later...............:(I would argue that statement is wrong, "fixed starter in FSX" depends upon you point of view. Regardless, I have written my own starter logic, fuel logic and mixture control logic for FSX that completely bypasses the screwed FSX logic as it applies to helicopters. This way I can control the helicopters engine parameters according to the way they SHOULD work as opposed to utilizing whatever FSX tries to default to.Steve

Share this post


Link to post
Share on other sites

>2 years later...............:(>>I would argue that statement is wrong, "fixed starter in FSX">depends upon you point of view. Patrick was referring to the "broken" TOGGLE_STARTER that didn't... "toggle" that is. In FS2002/4 the key event acted like a momentary switch, when in fact it "should have" (according to ACES' logic) acted as a toggle switch, hence the name... ;)Frankly, I would have preferred they change the name and leave it as a momentary contact switch, but that's just my opinion. :-wave NOTE: Would folks please turn off the bloody "plain text" option unless they're posting code snippets? :-rotor


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
Guest Skymed

Yup Patrick was correct, and I also wish they had not changed the way the starter works, but oh well, onwards and upwards.Steve

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...