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);