March 19, 200422 yr 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. :-) Matt KaprockiFor fastest support, please submit a ticket at http://support.precisionmanuals.com
March 23, 200422 yr 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
March 23, 200422 yr Moderator >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
November 7, 200421 yr 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;
November 8, 200421 yr This is great!While you can't filter it, you can probably undo it if you know what it was...
November 8, 200421 yr 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
May 13, 200521 yr >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
May 13, 200521 yr 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
December 11, 200619 yr 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?
December 11, 200619 yr >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
December 11, 200619 yr >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.
December 12, 200619 yr 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
December 12, 200619 yr Moderator >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
December 12, 200619 yr Yup Patrick was correct, and I also wish they had not changed the way the starter works, but oh well, onwards and upwards.Steve
Create an account or sign in to comment