Exemplo n.º 1
0
void setup()
{
	// Flightsim calling convention

	// Get the handle of the ACONTAIN.DLL module
	HMODULE hAContain = GetModuleHandle("ACONTAIN.DLL");

	// E) DELETE AN AI AIRCRAFT FROM THE FLIGHT SIMULATOR
	// If we got the handle of the ACONTAIN.DLL module then
	if (hAContain != NULL)
	{
		// Get a pointer to the ACONTAIN.DLL exported function
		FS10DeleteAIAircraft = (FS10ACONTAINDELETEAIAIRCRAFT)GetProcAddress(hAContain, (char*)7);
	}

	// load settings
	loadConfig(&conf);

	// Request an event when the simulation starts
	SimConnect_SubscribeToSystemEvent(hSimConnect, STARTUP, "SimStart");
	SimConnect_SubscribeToSystemEvent(hSimConnect, R2, "4sec");
	setupDataDefinition(hSimConnect);

	// setup menu and selection events
	SimConnect_MenuAddItem(hSimConnect, "AI Deleter Settings", MENU, 54321);
	SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP, MENU);
	SimConnect_MapClientEventToSimEvent(hSimConnect, MENU);
	SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP, MENU);
	SimConnect_SetNotificationGroupPriority(hSimConnect, MENU, SIMCONNECT_GROUP_PRIORITY_DEFAULT);
}
Exemplo n.º 2
0
void CSimCon::Connect(bool Flag)
{
	HRESULT hr;
	if ((!m_bConnected) && Flag)
	{
		if(SUCCEEDED (hr = SimConnect_Open (&m_hSimConnect, AppName, NULL, 0, 0, 0)))
		{
			hr = SimConnect_AddToDataDefinition (m_hSimConnect, DEFINITION_NAV, "NAV ACTIVE FREQUENCY:1", "Frequency BCD32", SIMCONNECT_DATATYPE_INT32);
			hr = SimConnect_AddToDataDefinition (m_hSimConnect, DEFINITION_NAV, "NAV STANDBY FREQUENCY:1", "Frequency BCD32", SIMCONNECT_DATATYPE_INT32);
			hr = SimConnect_AddToDataDefinition (m_hSimConnect, DEFINITION_ALT, "PLANE ALTITUDE", "feet", SIMCONNECT_DATATYPE_INT32);
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_UP_FLAPS, "FLAPS_INCR");
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_DN_FLAPS, "FLAPS_DECR");
			hr = SimConnect_SetNotificationGroupPriority (m_hSimConnect, GROUP_A, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
			hr = SimConnect_MenuAddItem (m_hSimConnect, "ffscocpkit", EVENT_MENU, NULL);
			hr = SimConnect_MenuAddSubItem (m_hSimConnect, EVENT_MENU, "Config COM", EVENT_MENU_COM, NULL);
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_NAV_INC, "NAV1_RADIO_FRACT_INC_CARRY");
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_NAV_DEC, "NAV1_RADIO_FRACT_DEC_CARRY");
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_NAV_BIG_INC, "NAV1_RADIO_WHOLE_INC");
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_NAV_BIG_DEC, "NAV1_RADIO_WHOLE_DEC");
			hr = SimConnect_MapClientEventToSimEvent (m_hSimConnect, EVENT_NAV_SWITCH, "NAV1_RADIO_SWAP");
			// Request an event when the simulation starts
			hr = SimConnect_SubscribeToSystemEvent (m_hSimConnect, EVENT_SIM_START, "SimStart");
			
			SimConnect_RequestDataOnSimObject (m_hSimConnect, REQUEST_NAV, DEFINITION_NAV, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SIM_FRAME, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED);
			SimConnect_RequestDataOnSimObject (m_hSimConnect, REQUEST_ALT, DEFINITION_ALT, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED);
			m_bConnected = true;
			TUpdate->Start(200);
			wxLogMessage(_("Connected on flight simulator"));
		}
		else
		{
			wxLogMessage(wxString::Format(_("Connection to Sim fail : %d"), hr));
		}
	}
	else if (m_bConnected && (!Flag))
	{
		m_bConnected = false;
		SimConnect_Close (m_hSimConnect);
		TUpdate->Stop();
		wxLogMessage(_("Disconnected from flight simulator"));
	}
}
Exemplo n.º 3
0
void testCockpitCamera()
{
	if (SUCCEEDED(SimConnect_Open(&hSimConnect, "Cockpit Camera", NULL, 0, 0, 0)))
	{
		cameraConfig = configLoader.load();

		SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_1, "title", NULL, SIMCONNECT_DATATYPE_STRINGV);

		SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");
		SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_AIRCRAFT_CHANGED, "AircraftLoaded");

		SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_STANDARD);

		REGISTER_CAMERA_BUTTON(1, "Num_1", "ctrl+Num_1");
		REGISTER_CAMERA_BUTTON(2, "Num_2", "ctrl+Num_2");
		REGISTER_CAMERA_BUTTON(3, "Num_3", "ctrl+Num_3");
		REGISTER_CAMERA_BUTTON(4, "Num_4", "ctrl+Num_4");
		REGISTER_CAMERA_BUTTON(5, "Num_5", "ctrl+Num_5");
		REGISTER_CAMERA_BUTTON(6, "Num_6", "ctrl+Num_6");
		REGISTER_CAMERA_BUTTON(7, "Num_7", "ctrl+Num_7");
		REGISTER_CAMERA_BUTTON(8, "Num_8", "ctrl+Num_8");
		REGISTER_CAMERA_BUTTON(9, "Num_9", "ctrl+Num_9");

		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_LEFT);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_RIGHT);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_UP);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_DOWN);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_FORWARD);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_BACK);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_HEADING_LEFT);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_HEADING_RIGHT);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_CENTER);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_PITCH_UP);
		SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_PITCH_DOWN);

		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_LEFT);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_RIGHT);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_UP);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_DOWN);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_FORWARD);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_BACK);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_HEADING_LEFT);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_HEADING_RIGHT);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_CENTER);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_PITCH_UP);
		SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP0, EVENT_PITCH_DOWN);

		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_4", EVENT_LEFT);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_6", EVENT_RIGHT);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_8", EVENT_UP);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_2", EVENT_DOWN);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_7", EVENT_FORWARD);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_1", EVENT_BACK);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_0", EVENT_HEADING_LEFT);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_Del", EVENT_HEADING_RIGHT);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_5", EVENT_CENTER);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_9", EVENT_PITCH_UP);
		SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+Num_3", EVENT_PITCH_DOWN);

		SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON);

		while (0 == quit)
		{
			SimConnect_CallDispatch(hSimConnect, MyDispatchProcCC, NULL);
			Sleep(1);
		}

		SimConnect_Close(hSimConnect);
	}

}
Exemplo n.º 4
0
void testCommunication()
{
	HRESULT hr;
	printf("Connecting to Flight Simulator!\n");

	if (SUCCEEDED(SimConnect_Open(&hSimConnect, "PMDG 777X Test", NULL, 0, 0, 0)))
	{
		printf("Connected to Flight Simulator!\n");

		// 1) Set up data connection

		// Associate an ID with the PMDG data area name
		hr = SimConnect_MapClientDataNameToID(hSimConnect, PMDG_777X_DATA_NAME, PMDG_777X_DATA_ID);

		// Define the data area structure - this is a required step
		hr = SimConnect_AddToClientDataDefinition(hSimConnect, PMDG_777X_DATA_DEFINITION, 0, sizeof(PMDG_777X_Data), 0, 0);

		// Sign up for notification of data change.  
		// SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED flag asks for the data to be sent only when some of the data is changed.
		hr = SimConnect_RequestClientData(hSimConnect, PMDG_777X_DATA_ID, DATA_REQUEST, PMDG_777X_DATA_DEFINITION,
			SIMCONNECT_CLIENT_DATA_PERIOD_ON_SET, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED, 0, 0, 0);


		// 2) Set up control connection

		// First method: control data area
		Control.Event = 0;
		Control.Parameter = 0;

		// Associate an ID with the PMDG control area name
		hr = SimConnect_MapClientDataNameToID(hSimConnect, PMDG_777X_CONTROL_NAME, PMDG_777X_CONTROL_ID);

		// Define the control area structure - this is a required step
		hr = SimConnect_AddToClientDataDefinition(hSimConnect, PMDG_777X_CONTROL_DEFINITION, 0, sizeof(PMDG_777X_Control), 0, 0);

		// Sign up for notification of control change.  
		hr = SimConnect_RequestClientData(hSimConnect, PMDG_777X_CONTROL_ID, CONTROL_REQUEST, PMDG_777X_CONTROL_DEFINITION,
			SIMCONNECT_CLIENT_DATA_PERIOD_ON_SET, SIMCONNECT_CLIENT_DATA_REQUEST_FLAG_CHANGED, 0, 0, 0);

		// Second method: Create event IDs for controls that we are going to operate
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_LOGO_LIGHT_SWITCH, "#69748");		//EVT_OH_LIGHTS_LOGO
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_FLIGHT_DIRECTOR_SWITCH, "#69834");	//EVT_MCP_FD_SWITCH_L


																										// 3) Request current aircraft .air file path
		hr = SimConnect_RequestSystemState(hSimConnect, AIR_PATH_REQUEST, "AircraftLoaded");
		// also request notifications on sim start and aircraft change
		hr = SimConnect_SubscribeToSystemEvent(hSimConnect, EVENT_SIM_START, "SimStart");


		// 4) Assign keyboard shortcuts
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_KEYBOARD_A);
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_KEYBOARD_B);
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_KEYBOARD_C);

		hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_KEYBOARD, EVENT_KEYBOARD_A);
		hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_KEYBOARD, EVENT_KEYBOARD_B);
		hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_KEYBOARD, EVENT_KEYBOARD_C);

		hr = SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP_KEYBOARD, SIMCONNECT_GROUP_PRIORITY_HIGHEST);

		hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+ctrl+a", EVENT_KEYBOARD_A);
		hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+ctrl+b", EVENT_KEYBOARD_B);
		hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "shift+ctrl+c", EVENT_KEYBOARD_C);

		hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON);

		printf("entering main loop\n");
		// 5) Main loop
		while (quit == 0)
		{
			//printf("running main loop\n");
			// receive and process the 777X data
			SimConnect_CallDispatch(hSimConnect, MyDispatchProc, NULL);

			Sleep(1);
		}

		hr = SimConnect_Close(hSimConnect);
	}
	else
		printf("Unable to connect!\n\n");
}