November 3, 200421 yr 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
November 3, 200421 yr Author 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 My Web Site
November 3, 200421 yr 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.
November 3, 200421 yr Moderator >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
November 4, 200421 yr Author 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 My Web Site
November 4, 200421 yr Author 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 My Web Site
November 4, 200421 yr 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?
November 5, 200421 yr Author 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 My Web Site
November 5, 200421 yr >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.
November 5, 200421 yr 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
November 6, 200421 yr >I believe I made a post about this a few months ago, but you>are correct in the fact that send_key_event should not trigger>the key repetition.:-) >>Edit: Can't find that post, so I guess I never actually posted>it. :dunce:Yes you did. :(It is right here:http://forums.avsim.net/dcboard.php?az=sho...ing_type=search
November 8, 200421 yr Author 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 My Web Site
November 9, 200421 yr Author For all of you that helped me with this topic, I have created a new one:http://forums.avsim.net/dcboard.php?az=sho..._id=20003&page=It explains how this handler can also be used to read the stick and throttle position, I think it can be useful.Eric My Web Site
Create an account or sign in to comment