bool CConnector::open(CConnector::FSVersion version) { if(FSUIPC_Open(version, &m_dwResult)) { m_bOpened = true; return true; } return false; }
int Simulator::Connect() { //Ensure any previous connections are closed first then connect to simulator. DWORD result; FSUIPC_Close(); if (FSUIPC_Open(SIM_ANY, &result) == TRUE) isConnected = true; else isConnected = false; return static_cast<int>(result); }
bool FSUIPC::openLink() { closeLink(); DWORD error = 0; #if VASFMC_GAUGE delete [] m_buffer; m_buffer=new BYTE[FSUIPC_BUFFER_SIZE]; int ret = FSUIPC_Open2(SIM_ANY, &error, m_buffer, FSUIPC_BUFFER_SIZE); #else int ret = FSUIPC_Open(SIM_ANY, &error); #endif if (!ret || error != FSUIPC_ERR_OK) { // printf("FSUIPC:openLink: Error: %s\n", getErrorText(error).toLatin1().data()); // fflush(stdout); return false; } m_link_ok = true; return true; };
// // Update Headpose in Game. // void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { DWORD result; TFSState pitch; TFSState yaw; TFSState roll; WORD FSZoom; float virtPosX; float virtPosY; float virtPosZ; float virtRotX; float virtRotY; float virtRotZ; // qDebug() << "FSUIPCServer::run() says: started!"; virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; virtRotZ = headpose[Roll]; virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! virtPosY = 0.0f; virtPosZ = headpose[TZ]; // // Init. the FSUIPC offsets (derived from Free-track...) // pitch.Control = 66503; yaw.Control = 66504; roll.Control = 66505; // // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. // if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { // // Open the connection // FSUIPC_Open(SIM_ANY, &result); // // Check the FS-version // if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { // qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; // // Write the 4! DOF-data to FS. Only rotations and zoom are possible. // pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); FSUIPC_Write(0x3110, 8, &pitch, &result); yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); FSUIPC_Write(0x3110, 8, &yaw, &result); roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); FSUIPC_Write(0x3110, 8, &roll, &result); FSZoom = (WORD) (64/50) * virtPosZ + 64; FSUIPC_Write(0x832E, 2, &FSZoom, &result); // // Write the data, in one go! // FSUIPC_Process(&result); if (result == FSUIPC_ERR_SENDMSG) { FSUIPC_Close(); //timeout (1 second) so assume FS closed } } } prevPosX = virtPosX; prevPosY = virtPosY; prevPosZ = virtPosZ; prevRotX = virtRotX; prevRotY = virtRotY; prevRotZ = virtRotZ; }
JNIEXPORT jint JNICALL Java_com_flightSim_wrapper_FSWrapper_Open(JNIEnv *, jclass, jint aFlightSim) { return FSUIPC_Open(aFlightSim, &iResult); }