• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Masking events using string name?

Messages
516
I seem to be having some trouble masking events using simconnect by the event name, i.e. "parking_brakes".

I can get the event to trigger a case in my callback by using the line:

hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_1,"PARKING_BRAKES");

But what I want to do is this:

hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_1, "PARKING_BRAKES", EVENT_1, 0, (SIMCONNECT_CLIENT_EVENT_ID)SIMCONNECT_UNUSED, 0, true);

so I can detect the event and mask it. But despite me setting:

hr = SimConnect_SetInputGroupPriority(hSimConnect, INPUT_1, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);

it never seems to get masked. Are these events with named strings generated from a layer lower than the highest maskable?

I know I can successfully mask raw keystrokes, but that's no good as it takes no account of the user's key configuration.

Any ideas?

Si
 
Ok, I finally figured it out before my sanity gave way...

What you have to do is:

hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_BRAKES,"BRAKES");

hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, INPUT_GROUP, EVENT_BRAKES,true);

hr = SimConnect_SetNotificationGroupPriority(hSimConnect, INPUT_GROUP, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);

hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_BRAKES, "", EVENT_BRAKES);

hr = SimConnect_SetInputGroupPriority(hSimConnect, INPUT_BRAKES, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);

hr = SimConnect_SetInputGroupState(hSimConnect,INPUT_BRAKES, state);

You can then trap for EVENT_BRAKES in a callback function.

The key here is to set the maskable flag in AddClientEventToNotificationGroup(), rather than MapInputEventToClientEvent().

And by specifying the event name in MapClientEventToSimEvent() you don't need to supply a string to MapInputEventToClientEvent() or make that maskable.

So, using this you can mask key strokes and joystick input based upon the internal events rather than the specific key codes and enumerated joystick axes read from the standard.xml, making it independent of the user's own control mappings.

Si
 
Back
Top