1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Masking events using string name?

Discussion in 'SimConnect' started by Simon853, 21/3/08.

  1. Simon853

    Simon853

    Joined:
    15/1/07
    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
  2. Simon853

    Simon853

    Joined:
    15/1/07
    Messages:
    516
    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

Share This Page