Possible misunderstanding of how maskable events work

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Post Reply
User avatar
DaiG
Posts: 324
Joined: Fri Jun 16, 2017 11:27 am
Location: The Kingdom of Mourne

Possible misunderstanding of how maskable events work

Post by DaiG »

I'm trying to set up a keyboard input:

Code: Select all

        // Set up a data definition for the throttle control
        hr = SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_THROTTLE, "GENERAL ENG THROTTLE LEVER POSITION:1", "percent");

        // Request a one-sec event which we'll use to connect
        hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_1SEC, "1sec");

        // Create two private key events to control the throttle
        hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_A);
        hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_S);

        // Sign up for notifications
        hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_KEYS, EVENT_A, true);
        hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_KEYS, EVENT_S, true);

        // Link the events to the keyboard
        hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_KEYS, "A", EVENT_A, true);
        hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT_KEYS, "S", EVENT_S, true);

        // Set a high priority for the group
        hr = SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP_KEYS, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);

        // Set the input to the highest priority
        hr = SimConnect_SetInputGroupPriority(hSimConnect, INPUT_KEYS, SIMCONNECT_GROUP_PRIORITY_HIGHEST_MASKABLE);

        // Ensure the input events are on
        hr = SimConnect_SetInputGroupState(hSimConnect, INPUT_KEYS, SIMCONNECT_STATE_ON);
What I expected from that is the A and S keys would be intercepted and increase/decrease the throttle (they do). What also happens - which I did not expect - is that the A key changes the internal views and the S key changes the external views at the same time as changing the throttle setting. I thought that masking the key inputs would prevent the keypresses from going through to prepar3d.exe?
PILOT'S developer
i9-12000KF
64Gb DDR4
RTX3080Ti
Western Digital 2Tb NVMe drive for P3D
m/b Z690 chipset
Post Reply