X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FATC-Inputs.cxx;h=4c6164928d1474ce6b6f41727b17a821975f56d2;hb=c1f250fd3340acb6b74603ba71771b441d7e7bb3;hp=3209827e0dc488760eba0df36b49c45d9a4416e9;hpb=61ed285d06ace1840aac7d100bac85d762866fe4;p=flightgear.git diff --git a/src/Network/ATC-Inputs.cxx b/src/Network/ATC-Inputs.cxx index 3209827e0..4c6164928 100644 --- a/src/Network/ATC-Inputs.cxx +++ b/src/Network/ATC-Inputs.cxx @@ -31,6 +31,8 @@ # include # include # include +# include +# include #endif #include @@ -222,7 +224,8 @@ bool FGATCInput::open() { ///////////////////////////////////////////////////////////////////// // scale a number between min and max (with center defined) to a scale -// from -1.0 to 1.0 +// from -1.0 to 1.0. The deadband value is symmetric, so specifying +// '1' will give you a deadband of +/-1 static double scale( int center, int deadband, int min, int max, int value ) { // cout << center << " " << min << " " << max << " " << value << " "; double result; @@ -231,9 +234,11 @@ static double scale( int center, int deadband, int min, int max, int value ) { if ( value <= (center - deadband) ) { range = (center - deadband) - min; result = (value - (center - deadband)) / range; - } else { + } else if ( value >= (center + deadband) ) { range = max - (center + deadband); result = (value - (center + deadband)) / range; + } else { + result = 0.0; } if ( result < -1.0 ) result = -1.0;