diff --git a/C/src/xplaneConnect.c b/C/src/xplaneConnect.c index 4d04972..cf71557 100755 --- a/C/src/xplaneConnect.c +++ b/C/src/xplaneConnect.c @@ -373,7 +373,7 @@ short sendPOSI(struct xpcSocket recfd, short ACNum, short numArgs, float valueAr short sendCTRL(struct xpcSocket recfd, short numArgs, float valueArray[]) { - char message[29] = {0}; + char message[26] = {0}; int i; short position = 5; @@ -396,12 +396,21 @@ short sendCTRL(struct xpcSocket recfd, short numArgs, float valueArray[]) val = valueArray[i]; } - // Float Values - memcpy(&message[position],&val,sizeof(float)); - position += sizeof(float); + if (i==4) // Integer-gear + { + message[position] = (short int) val; + position += 1; + } + else // float + { + // Float Values + memcpy(&message[position],&val,sizeof(float)); + position += sizeof(float); + } + } - sendUDP(recfd, message, 29); + sendUDP(recfd, message, 26); return 0; } diff --git a/TestScripts/C Tests/main.c b/TestScripts/C Tests/main.c index c66a46d..08dfc47 100644 --- a/TestScripts/C Tests/main.c +++ b/TestScripts/C Tests/main.c @@ -238,7 +238,7 @@ short sendCTRLTest() // sendCTRL test // Initialize int i; // Iterator char DREFArray[100][100]; - float CTRL[5] = {0.0}; + float CTRL[6] = {0.0}; float *recDATA[100]; short DREFSizes[100]; struct xpcSocket sendPort, recvPort; @@ -256,14 +256,16 @@ short sendCTRLTest() // sendCTRL test strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio"); strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro"); strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status"); - strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqsts"); + strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqst"); for (i = 0; i < 100; i++) { DREFSizes[i] = (int)strlen(DREFArray[i]); } CTRL[3] = 0.8; // Throttle + CTRL[4] = 1; // Gear + CTRL[5] = 0.5; // Flaps // Execute - sendCTRL(sendPort, 4, CTRL); + sendCTRL(sendPort, 6, CTRL); result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test // Close @@ -275,9 +277,9 @@ short sendCTRLTest() // sendCTRL test { return -6; } - for (i=0;i<6-1;i++) + for (i=0;i<6;i++) { - if (abs(recDATA[i][0]-CTRL[i])>1e-4) + if (fabs(recDATA[i][0]-CTRL[i])>1e-4) { return -i; } @@ -343,7 +345,7 @@ short sendPOSITest() // sendPOSI test { continue; } - if (abs(recDATA[i][0]-POSI[i])>1e-4) + if (fabs(recDATA[i][0]-POSI[i])>1e-4) { return -i; } diff --git a/TestScripts/CPP Tests/main.cpp b/TestScripts/CPP Tests/main.cpp index a32a1d9..f69e7ef 100755 --- a/TestScripts/CPP Tests/main.cpp +++ b/TestScripts/CPP Tests/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include "xplaneconnect.h" @@ -237,7 +238,7 @@ void sendCTRLTest() // sendCTRL test // Initialize int i; // Iterator char DREFArray[100][100]; - float CTRL[5] = {0.0}; + float CTRL[6] = {0.0}; float *recDATA[100]; short DREFSizes[100]; struct xpcSocket sendPort, recvPort; @@ -255,14 +256,16 @@ void sendCTRLTest() // sendCTRL test strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio"); strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro"); strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status"); - strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqsts"); + strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqst"); for (i = 0; i < 100; i++) { DREFSizes[i] = (int)strlen(DREFArray[i]); } CTRL[3] = 0.8; // Throttle + CTRL[4] = 1.0; // Gear + CTRL[5] = 0.5; // Flaps // Execute - sendCTRL(sendPort, 4, CTRL); + sendCTRL(sendPort, 6, CTRL); result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test // Close @@ -274,9 +277,9 @@ void sendCTRLTest() // sendCTRL test { throw -6; } - for (i=0;i<6-1;i++) + for (i=0;i<6;i++) { - if (abs(recDATA[i][0]-CTRL[i])>1e-4) + if (std::abs( recDATA[i][0]-CTRL[i])>1e-4) { throw -i; } @@ -340,7 +343,7 @@ void sendPOSITest() // sendPOSI test { continue; } - if (abs(recDATA[i][0]-POSI[i])>1e-4) + if (std::abs(recDATA[i][0]-POSI[i])>1e-4) { throw -i; } diff --git a/xpcPlugin/XPCPlugin.cpp b/xpcPlugin/XPCPlugin.cpp index adc5cf5..5776f8b 100755 --- a/xpcPlugin/XPCPlugin.cpp +++ b/xpcPlugin/XPCPlugin.cpp @@ -755,7 +755,7 @@ int handleCTRL(char buf[]) { setGEAR(0, gear, 0); // Gear } - if ( flaps > -999.5 && flaps < -997.5 ) // Flaps + if ( flaps < -999.5 || flaps > -997.5 ) // Flaps { XPLMSetDataf(XPLMDataRefs[13][3],flaps); } diff --git a/xpcPlugin/XPlaneConnect/64/win.xpl b/xpcPlugin/XPlaneConnect/64/win.xpl index 1b01e24..d17bce8 100644 Binary files a/xpcPlugin/XPlaneConnect/64/win.xpl and b/xpcPlugin/XPlaneConnect/64/win.xpl differ diff --git a/xpcPlugin/XPlaneConnect/mac.xpl b/xpcPlugin/XPlaneConnect/mac.xpl old mode 100644 new mode 100755 index 2a11344..fd4150c Binary files a/xpcPlugin/XPlaneConnect/mac.xpl and b/xpcPlugin/XPlaneConnect/mac.xpl differ diff --git a/xpcPlugin/XPlaneConnect/win.xpl b/xpcPlugin/XPlaneConnect/win.xpl index da25d8a..6f2676d 100644 Binary files a/xpcPlugin/XPlaneConnect/win.xpl and b/xpcPlugin/XPlaneConnect/win.xpl differ diff --git a/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj b/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj index 15803f7..c4d69d2 100755 --- a/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj +++ b/xpcPlugin/xpcPlugin.xcodeproj/project.pbxproj @@ -9,7 +9,7 @@ /* Begin PBXBuildFile section */ BE37D960187C8B0F0033B082 /* XPCPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */; }; BE5F2FF118FCA1D500AFCD17 /* xpcPluginTools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */; }; - BE8361EF18C5591C00E9C923 /* xpcPlugin.xpl in CopyFiles */ = {isa = PBXBuildFile; fileRef = D607B19909A556E400699BC3 /* xpcPlugin.xpl */; }; + BE8361EF18C5591C00E9C923 /* mac.xpl in CopyFiles */ = {isa = PBXBuildFile; fileRef = D607B19909A556E400699BC3 /* mac.xpl */; }; BEDC620418EDF1A7005DB364 /* xplaneConnect.c in Sources */ = {isa = PBXBuildFile; fileRef = BEDC620218EDF1A7005DB364 /* xplaneConnect.c */; }; D6A7BDAA16A1DEA200D1426A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDA916A1DEA200D1426A /* OpenGL.framework */; }; D6A7BDC116A1DEC000D1426A /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDC016A1DEC000D1426A /* CoreFoundation.framework */; }; @@ -21,10 +21,10 @@ BE8361EE18C5591600E9C923 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 12; - dstPath = "/Applications/X-Plane 10/Resources/plugins"; + dstPath = "/Applications/X-Plane 10/Resources/plugins/XPlaneConnect"; dstSubfolderSpec = 0; files = ( - BE8361EF18C5591C00E9C923 /* xpcPlugin.xpl in CopyFiles */, + BE8361EF18C5591C00E9C923 /* mac.xpl in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -37,7 +37,7 @@ BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xpcPluginTools.cpp; sourceTree = ""; }; BEDC620218EDF1A7005DB364 /* xplaneConnect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../C/src/xplaneConnect.c; sourceTree = ""; }; BEDC620318EDF1A7005DB364 /* xplaneConnect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../C/src/xplaneConnect.h; sourceTree = ""; }; - D607B19909A556E400699BC3 /* xpcPlugin.xpl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = xpcPlugin.xpl; sourceTree = BUILT_PRODUCTS_DIR; }; + D607B19909A556E400699BC3 /* mac.xpl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = mac.xpl; sourceTree = BUILT_PRODUCTS_DIR; }; D6A7BDA916A1DEA200D1426A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; D6A7BDC016A1DEC000D1426A /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; D6A7BDF016A1DED200D1426A /* XPLM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XPLM.framework; path = SDK/Libraries/Mac/XPLM.framework; sourceTree = ""; }; @@ -84,7 +84,7 @@ D607B19A09A556E400699BC3 /* Products */ = { isa = PBXGroup; children = ( - D607B19909A556E400699BC3 /* xpcPlugin.xpl */, + D607B19909A556E400699BC3 /* mac.xpl */, ); name = Products; sourceTree = ""; @@ -117,7 +117,7 @@ ); name = xpcPlugin; productName = StarterPlugin; - productReference = D607B19909A556E400699BC3 /* xpcPlugin.xpl */; + productReference = D607B19909A556E400699BC3 /* mac.xpl */; productType = "com.apple.product-type.library.dynamic"; }; /* End PBXNativeTarget section */ @@ -165,7 +165,7 @@ D607B16309A5563100699BC3 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CONFIGURATION_BUILD_DIR = ./Mac; + CONFIGURATION_BUILD_DIR = ./XPlaneConnect; DYLIB_COMPATIBILITY_VERSION = ""; DYLIB_CURRENT_VERSION = ""; EXECUTABLE_EXTENSION = xpl; @@ -284,7 +284,7 @@ "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/xplaneConnect-asdjuezcjkhojuewbyxhyhabxfwc/Build/Products/Debug", ); MACH_O_TYPE = mh_bundle; - PRODUCT_NAME = xpcPlugin; + PRODUCT_NAME = mac; STRIP_INSTALLED_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = XPC; @@ -322,7 +322,7 @@ "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/xplaneConnect-asdjuezcjkhojuewbyxhyhabxfwc/Build/Products/Debug", ); MACH_O_TYPE = mh_bundle; - PRODUCT_NAME = xpcPlugin; + PRODUCT_NAME = mac; STRIP_INSTALLED_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = XPC;