From 3a7cef79c8c264f9a3fb5b5e0abc28e2c21d532a Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 10 Sep 2004 17:53:34 +0000 Subject: [PATCH] Add support for "co-pilot" toe brakes. --- src/Controls/controls.cxx | 30 +++++++++++++++++++++++++++++- src/Controls/controls.hxx | 6 ++++++ src/Network/native_ctrls.cxx | 12 ++++++++++++ src/Network/net_ctrls.hxx | 4 +++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/Controls/controls.cxx b/src/Controls/controls.cxx index 22a695814..a36ee4d9d 100644 --- a/src/Controls/controls.cxx +++ b/src/Controls/controls.cxx @@ -74,6 +74,8 @@ FGControls::FGControls() : dump_valve( false ), brake_left( 0.0 ), brake_right( 0.0 ), + copilot_brake_left( 0.0 ), + copilot_brake_right( 0.0 ), brake_parking( 0.0 ), steering( 0.0 ), gear_down( true ), @@ -204,7 +206,9 @@ FGControls::init () condition[engine] = 1.0; } - brake_left = brake_right = brake_parking = 0.0; + brake_left = brake_right + = copilot_brake_left = copilot_brake_right + = brake_parking = 0.0; for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) { alternate_extension[wheel] = false; } @@ -433,6 +437,16 @@ FGControls::bind () &FGControls::set_brake_right); fgSetArchivable("/controls/gear/brake-right"); + fgTie("/controls/gear/copilot-brake-left", this, + &FGControls::get_copilot_brake_left, + &FGControls::set_copilot_brake_left); + fgSetArchivable("/controls/gear/copilot-brake-left"); + + fgTie("/controls/gear/copilot-brake-right", this, + &FGControls::get_copilot_brake_right, + &FGControls::set_copilot_brake_right); + fgSetArchivable("/controls/gear/copilot-brake-right"); + fgTie("/controls/gear/brake-parking", this, &FGControls::get_brake_parking, &FGControls::set_brake_parking); @@ -1628,6 +1642,20 @@ FGControls::move_brake_right( double amt ) CLAMP( &brake_right, 0.0, 1.0 ); } +void +FGControls::set_copilot_brake_left( double pos ) +{ + copilot_brake_left = pos; + CLAMP(&brake_left, 0.0, 1.0); +} + +void +FGControls::set_copilot_brake_right( double pos ) +{ + copilot_brake_right = pos; + CLAMP(&brake_right, 0.0, 1.0); +} + void FGControls::set_brake_parking( double pos ) { diff --git a/src/Controls/controls.hxx b/src/Controls/controls.hxx index 209e26d79..82f9b9233 100644 --- a/src/Controls/controls.hxx +++ b/src/Controls/controls.hxx @@ -156,6 +156,8 @@ private: // controls/gear/ double brake_left; double brake_right; + double copilot_brake_left; + double copilot_brake_right; double brake_parking; double steering; bool gear_down; @@ -336,6 +338,8 @@ public: // controls/gear/ inline double get_brake_left() const { return brake_left; } inline double get_brake_right() const { return brake_right; } + inline double get_copilot_brake_left() const { return copilot_brake_left; } + inline double get_copilot_brake_right() const { return copilot_brake_right; } inline double get_brake_parking() const { return brake_parking; } inline double get_steering() const { return steering; } inline bool get_gear_down() const { return gear_down; } @@ -519,6 +523,8 @@ public: void move_brake_left( double amt ); void set_brake_right( double pos ); void move_brake_right( double amt ); + void set_copilot_brake_left( double pos ); + void set_copilot_brake_right( double pos ); void set_brake_parking( double pos ); void set_steering( double pos ); void move_steering( double amt ); diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index c8453e1f8..4d2051a35 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -187,6 +187,10 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, node = fgGetNode("/controls/gear", true); net->brake_left = node->getChild("brake-left")->getDoubleValue(); net->brake_right = node->getChild("brake-right")->getDoubleValue(); + net->copilot_brake_left + = node->getChild("copilot-brake-left")->getDoubleValue(); + net->copilot_brake_right + = node->getChild("copilot-brake-right")->getDoubleValue(); net->brake_parking = node->getChild("brake-parking")->getDoubleValue(); net->gear_handle = fgGetBool( "controls/gear/gear-down" ); @@ -262,6 +266,8 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool honor_freezes, net->num_tanks = htonl(net->num_tanks); htond(net->brake_left); htond(net->brake_right); + htond(net->copilot_brake_left); + htond(net->copilot_brake_right); htond(net->brake_parking); net->gear_handle = htonl(net->gear_handle); net->master_avionics = htonl(net->master_avionics); @@ -321,6 +327,8 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, } htond(net->brake_left); htond(net->brake_right); + htond(net->copilot_brake_left); + htond(net->copilot_brake_right); htond(net->brake_parking); net->gear_handle = htonl(net->gear_handle); net->master_avionics = htonl(net->master_avionics); @@ -390,6 +398,10 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool honor_freezes, if ( node != NULL ) { node->getChild( "brake-left" )->setDoubleValue( net->brake_left ); node->getChild( "brake-right" )->setDoubleValue( net->brake_right ); + node->getChild( "copilot-brake-left" ) + ->setDoubleValue( net->copilot_brake_left ); + node->getChild( "copilot-brake-right" ) + ->setDoubleValue( net->copilot_brake_right ); node->getChild( "brake-parking" )->setDoubleValue( net->brake_parking ); } diff --git a/src/Network/net_ctrls.hxx b/src/Network/net_ctrls.hxx index cc6ae5af9..1508b7ac5 100644 --- a/src/Network/net_ctrls.hxx +++ b/src/Network/net_ctrls.hxx @@ -16,7 +16,7 @@ # error This library requires C++ #endif -const int FG_NET_CTRLS_VERSION = 22; +const int FG_NET_CTRLS_VERSION = 23; // Define a structure containing the control parameters @@ -71,6 +71,8 @@ public: // Brake controls double brake_left; double brake_right; + double copilot_brake_left; + double copilot_brake_right; double brake_parking; // Landing Gear