/** callback for module loaded */ void FSC_CALLBACK_ModuleLoaded(HANDLE hSim) { FSC_Log("Initializing Kneeboard"); kneeboard_init(FSC_GetFlightSimWindow(), FSC_GetModuleHandle()); // hook up into window events pSimWindowProc = (WNDPROC)SetWindowLong(FSC_GetFlightSimWindow(), GWL_WNDPROC, (LONG)InterceptingWindowProc); if (pSimWindowProc==0) { char message[] = "SetWindowLong(\"handle, GWL_WNDPROC, proc\") returned null - PDFKneeboard keyboard shortcuts won't work"; FSC_Log(message); MessageBox(NULL, message, "PDFKneeboard", MB_OK | MB_ICONEXCLAMATION); return; } // start listening SimConnect_SubscribeToSystemEvent(hSim, EVENT_TIMER, "6Hz"); SimConnect_SubscribeToSystemEvent(hSim, EVENT_SIM, "Sim"); // setup menus SimConnect_MenuAddItem(hSim, "&PDFKneeboard", EVENT_MENU, 0); SimConnect_MenuAddSubItem(hSim, EVENT_MENU, "Show &Kneeboard", EVENT_MENU_SHOW, 0); SimConnect_MenuAddSubItem(hSim, EVENT_MENU, "&Hide Kneeboard", EVENT_MENU_HIDE, 0); SimConnect_MenuAddSubItem(hSim, EVENT_MENU, "&Open Document", EVENT_MENU_OPEN, 0); SimConnect_MenuAddSubItem(hSim, EVENT_MENU, "&Close Document", EVENT_MENU_CLOSE, 0); SimConnect_MenuAddSubItem(hSim, EVENT_MENU, "&Settings...", EVENT_MENU_SETTINGS, 0); // done }
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); }
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")); } }