Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

send_key_event

Featured Replies

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

  • 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

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.

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

  • 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

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?

  • 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

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

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

  • 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

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.