]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/native_ctrls.cxx
Updated adf property names.
[flightgear.git] / src / Network / native_ctrls.cxx
index 27f7b3694e9081bfa0f7d3eb0714fd2b70c65346..6f512b8e5ac82a6a281073d447e3eba92e5f2c07 100644 (file)
@@ -24,6 +24,8 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/io/iochannel.hxx>
 
+#include <Scenery/scenery.hxx> // ground elevation
+
 #include "native_ctrls.hxx"
 
 
@@ -55,40 +57,51 @@ bool FGNativeCtrls::open() {
 }
 
 
-static void global2raw( FGControls *global, FGRawCtrls *raw ) {
+static void global2raw( const FGControls *global, FGRawCtrls *raw ) {
     int i;
 
+    raw->version = FG_RAW_CTRLS_VERSION;
     raw->aileron = globals->get_controls()->get_aileron();
     raw->elevator = globals->get_controls()->get_elevator();
     raw->elevator_trim = globals->get_controls()->get_elevator_trim();
     raw->rudder = globals->get_controls()->get_rudder();
     raw->flaps = globals->get_controls()->get_flaps();
-    for ( i = 0; i < FG_MAX_ENGINES; ++i ) {    
+    for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) {    
        raw->throttle[i] = globals->get_controls()->get_throttle(i);
        raw->mixture[i] = globals->get_controls()->get_mixture(i);
        raw->prop_advance[i] = globals->get_controls()->get_prop_advance(i);
     }
-    for ( i = 0; i < FG_MAX_WHEELS; ++i ) {
+    for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
        raw->brake[i] =  globals->get_controls()->get_brake(i);
     }
+
+    raw->hground = globals->get_scenery()->get_cur_elev();
 }
 
 
-static void raw2global( FGRawCtrls *raw, FGControls *global ) {
+static void raw2global( const FGRawCtrls *raw, FGControls *global ) {
     int i;
 
-    globals->get_controls()->set_aileron( raw->aileron );
-    globals->get_controls()->set_elevator( raw->elevator );
-    globals->get_controls()->set_elevator_trim( raw->elevator_trim );
-    globals->get_controls()->set_rudder( raw->rudder );
-    globals->get_controls()->set_flaps( raw->flaps );
-    for ( i = 0; i < FG_MAX_ENGINES; ++i ) {    
-       globals->get_controls()->set_throttle( i, raw->throttle[i] );
-       globals->get_controls()->set_mixture( i, raw->mixture[i] );
-       globals->get_controls()->set_prop_advance( i, raw->prop_advance[i] );
-    }
-    for ( i = 0; i < FG_MAX_WHEELS; ++i ) {
-       globals->get_controls()->set_brake( i, raw->brake[i] );
+    if ( raw->version == FG_RAW_CTRLS_VERSION ) {
+       globals->get_controls()->set_aileron( raw->aileron );
+       globals->get_controls()->set_elevator( raw->elevator );
+       globals->get_controls()->set_elevator_trim( raw->elevator_trim );
+       globals->get_controls()->set_rudder( raw->rudder );
+       globals->get_controls()->set_flaps( raw->flaps );
+       for ( i = 0; i < FGRawCtrls::FG_MAX_ENGINES; ++i ) {    
+           globals->get_controls()->set_throttle( i, raw->throttle[i] );
+           globals->get_controls()->set_mixture( i, raw->mixture[i] );
+           globals->get_controls()->set_prop_advance( i, raw->prop_advance[i]);
+       }
+       for ( i = 0; i < FGRawCtrls::FG_MAX_WHEELS; ++i ) {
+           globals->get_controls()->set_brake( i, raw->brake[i] );
+       }
+       globals->get_controls()->set_gear_down( raw->gear_handle );
+       globals->get_scenery()->set_cur_elev( raw->hground );
+    } else {
+       SG_LOG( SG_IO, SG_ALERT, "Error: version mismatch in raw2global()" );
+       SG_LOG( SG_IO, SG_ALERT,
+               "\tsomeone needs to upgrade raw_ctrls.hxx and recompile." );
     }
 }