#include <simgear/compiler.h>
+#include <ctype.h>
+
#include STL_FSTREAM
#include STL_STRING
////////////////////////////////////////////////////////////////////////
FGBinding::FGBinding ()
- : _action(ACTION_NONE), _node(0), _adjust_step(0), _assign_value(0)
+ : _action(ACTION_NONE), _node(0), _adjust_step(0), _assign_value(0)
{
}
FGBinding::FGBinding (const SGPropertyNode * node)
- : _action(ACTION_NONE), _node(0), _adjust_step(0), _assign_value(0)
+ : _action(ACTION_NONE), _node(0), _adjust_step(0), _assign_value(0)
{
- read(node);
+ read(node);
}
FGBinding::~FGBinding ()
{
- // no op
+ // no op
}
void
FGBinding::setAction (Action action)
{
- _action = action;
+ _action = action;
}
void
FGBinding::setProperty (SGPropertyNode * node)
{
- _node = node;
+ _node = node;
}
void
FGBinding::setAdjustStep (const SGValue * step)
{
- _adjust_step = step;
+ _adjust_step = step;
}
void
FGBinding::setAssignValue (const SGValue * value)
{
- _assign_value = value;
+ _assign_value = value;
}
void
FGBinding::read (const SGPropertyNode * node)
{
- if (node->hasValue("action")) {
- string action = node->getStringValue("action");
- if (action == "none")
- _action = ACTION_NONE;
- else if (action == "switch")
- _action = ACTION_SWITCH;
- else if (action == "adjust")
- _action = ACTION_ADJUST;
- else if (action == "assign")
- _action = ACTION_ASSIGN;
- else
- SG_LOG(SG_INPUT, SG_ALERT, "Ignoring unrecognized action type "
- << action);
- }
-
- if (node->hasValue("control"))
- _node = fgGetNode(node->getStringValue("control"), true);
-
- if (node->hasValue("step"))
- _adjust_step = node->getChild("step")->getValue();
-
- if (node->hasValue("value"))
- _assign_value = node->getChild("value")->getValue();
+ if (node->hasValue("action")) {
+ string action = node->getStringValue("action");
+ if (action == "none")
+ _action = ACTION_NONE;
+ else if (action == "switch")
+ _action = ACTION_SWITCH;
+ else if (action == "adjust")
+ _action = ACTION_ADJUST;
+ else if (action == "assign")
+ _action = ACTION_ASSIGN;
+ else
+ SG_LOG(SG_INPUT, SG_ALERT, "Ignoring unrecognized action type "
+ << action);
+ }
+
+ if (node->hasValue("control"))
+ _node = fgGetNode(node->getStringValue("control"), true);
+
+ if (node->hasValue("step"))
+ _adjust_step = node->getChild("step")->getValue();
+
+ if (node->hasValue("value"))
+ _assign_value = node->getChild("value")->getValue();
}
void
FGBinding::fire () const
{
- if (_node == 0) {
- SG_LOG(SG_INPUT, SG_ALERT, "No control property attached to binding");
- return;
- }
+ if (_node == 0) {
+ SG_LOG(SG_INPUT, SG_ALERT, "No control property attached to binding");
+ return;
+ }
- switch (_action) {
+ switch (_action) {
- case ACTION_NONE:
- break;
+ case ACTION_NONE:
+ break;
- case ACTION_SWITCH:
- _node->setBoolValue(!_node->getBoolValue());
- break;
+ case ACTION_SWITCH:
+ _node->setBoolValue(!_node->getBoolValue());
+ break;
- case ACTION_ADJUST:
- if (_adjust_step == 0) {
- SG_LOG(SG_INPUT, SG_ALERT, "No step provided for adjust binding");
- break;
- }
- switch (_node->getType()) {
- case SGValue::BOOL:
- if (_adjust_step->getBoolValue())
- _node->setBoolValue(!_node->getBoolValue());
- break;
- case SGValue::INT:
- _node->setIntValue(_node->getIntValue() + _adjust_step->getIntValue());
- break;
- case SGValue::LONG:
- _node->setLongValue(_node->getLongValue() + _adjust_step->getLongValue());
- break;
- case SGValue::FLOAT:
- _node->setFloatValue(_node->getFloatValue()
- + _adjust_step->getFloatValue());
- break;
- case SGValue::DOUBLE:
- case SGValue::UNKNOWN: // force to double
- _node->setDoubleValue(_node->getDoubleValue()
- + _adjust_step->getDoubleValue());
- break;
- case SGValue::STRING:
- SG_LOG(SG_INPUT, SG_ALERT, "Cannot increment or decrement string value"
- << _node->getStringValue());
- break;
- }
- break;
+ case ACTION_ADJUST:
+ if (_adjust_step == 0) {
+ SG_LOG(SG_INPUT, SG_ALERT, "No step provided for adjust binding");
+ break;
+ }
+ switch (_node->getType()) {
+ case SGValue::BOOL:
+ if (_adjust_step->getBoolValue())
+ _node->setBoolValue(!_node->getBoolValue());
+ break;
+ case SGValue::INT:
+ _node->setIntValue(_node->getIntValue() + _adjust_step->getIntValue());
+ break;
+ case SGValue::LONG:
+ _node->setLongValue(_node->getLongValue() + _adjust_step->getLongValue());
+ break;
+ case SGValue::FLOAT:
+ _node->setFloatValue(_node->getFloatValue()
+ + _adjust_step->getFloatValue());
+ break;
+ case SGValue::DOUBLE:
+ case SGValue::UNKNOWN: // force to double
+ _node->setDoubleValue(_node->getDoubleValue()
+ + _adjust_step->getDoubleValue());
+ break;
+ case SGValue::STRING:
+ SG_LOG(SG_INPUT, SG_ALERT, "Cannot increment or decrement string value"
+ << _node->getStringValue());
+ break;
+ }
+ break;
- case ACTION_ASSIGN:
- if (_assign_value == 0) {
- SG_LOG(SG_INPUT, SG_ALERT, "No value provided for assign binding");
- break;
- }
- switch (_node->getType()) {
- case SGValue::BOOL:
- _node->setBoolValue(_assign_value->getBoolValue());
- break;
- case SGValue::INT:
- _node->setIntValue(_assign_value->getIntValue());
- break;
- case SGValue::LONG:
- _node->setLongValue(_assign_value->getLongValue());
- break;
- case SGValue::FLOAT:
- _node->setFloatValue(_assign_value->getFloatValue());
- break;
- case SGValue::DOUBLE:
- _node->setDoubleValue(_assign_value->getDoubleValue());
- break;
- case SGValue::STRING:
- _node->setStringValue(_assign_value->getStringValue());
- break;
- case SGValue::UNKNOWN:
- _node->setUnknownValue(_assign_value->getStringValue());
- break;
+ case ACTION_ASSIGN:
+ if (_assign_value == 0) {
+ SG_LOG(SG_INPUT, SG_ALERT, "No value provided for assign binding");
+ break;
+ }
+ switch (_node->getType()) {
+ case SGValue::BOOL:
+ _node->setBoolValue(_assign_value->getBoolValue());
+ break;
+ case SGValue::INT:
+ _node->setIntValue(_assign_value->getIntValue());
+ break;
+ case SGValue::LONG:
+ _node->setLongValue(_assign_value->getLongValue());
+ break;
+ case SGValue::FLOAT:
+ _node->setFloatValue(_assign_value->getFloatValue());
+ break;
+ case SGValue::DOUBLE:
+ _node->setDoubleValue(_assign_value->getDoubleValue());
+ break;
+ case SGValue::STRING:
+ _node->setStringValue(_assign_value->getStringValue());
+ break;
+ case SGValue::UNKNOWN:
+ _node->setUnknownValue(_assign_value->getStringValue());
+ break;
+ }
+ break;
}
- break;
- }
}
// Implementation of FGInput.
////////////////////////////////////////////////////////////////////////
- // From main.cxx
+// From main.cxx
extern void fgReshape( int width, int height );
FGInput current_input;
FGInput::FGInput ()
{
- // no op
+ // no op
}
FGInput::~FGInput ()
{
- // no op
+ // no op
}
void
FGInput::init ()
{
- // Read the keyboard bindings.
- // TODO: zero the old bindings first.
- const SGPropertyNode * keyboard =
- globals->get_props()->getNode("/input/keyboard", true);
- vector<const SGPropertyNode *> keys = keyboard->getChildren("key");
-
- for (unsigned int i = 0; i < keys.size(); i++) {
- int index = keys[i]->getIndex();
- int modifiers = FG_MOD_NONE;
- if (keys[i]->getBoolValue("mod-shift"))
- modifiers |= FG_MOD_SHIFT;
- if (keys[i]->getBoolValue("mod-ctrl"))
- modifiers |= FG_MOD_CTRL;
- if (keys[i]->getBoolValue("mod-alt"))
- modifiers |= FG_MOD_ALT;
- SG_LOG(SG_INPUT, SG_INFO, "Binding key " << index
- << " with modifiers " << modifiers);
-
- vector<const SGPropertyNode *> bindings = keys[i]->getChildren("binding");
- for (unsigned int j = 0; j < bindings.size(); j++) {
- SG_LOG(SG_INPUT, SG_INFO, " Adding binding " << j);
- _key_bindings[modifiers][index].push_back(FGBinding(bindings[j]));
+ // Read the keyboard bindings.
+ // TODO: zero the old bindings first.
+ const SGPropertyNode * keyboard =
+ globals->get_props()->getNode("/input/keyboard", true);
+ vector<const SGPropertyNode *> keys = keyboard->getChildren("key");
+
+ for (unsigned int i = 0; i < keys.size(); i++) {
+ int code = keys[i]->getIndex();
+ int modifiers = FG_MOD_NONE;
+ if (keys[i]->getBoolValue("mod-shift"))
+ modifiers |= FG_MOD_SHIFT;
+ if (keys[i]->getBoolValue("mod-ctrl"))
+ modifiers |= FG_MOD_CTRL;
+ if (keys[i]->getBoolValue("mod-alt"))
+ modifiers |= FG_MOD_ALT;
+
+ if (code < 0) {
+ SG_LOG(SG_INPUT, SG_ALERT, "Key stroke not bound = "
+ << keys[i]->getStringValue("name", "[unnamed]"));
+ } else {
+ SG_LOG(SG_INPUT, SG_INFO, "Binding key " << code
+ << " with modifiers " << modifiers);
+ vector<const SGPropertyNode *> bindings =
+ keys[i]->getChildren("binding");
+ for (unsigned int j = 0; j < bindings.size(); j++) {
+ SG_LOG(SG_INPUT, SG_INFO, " Adding binding " << j);
+ _key_bindings[modifiers][code].push_back(FGBinding(bindings[j]));
+ }
+ }
}
- }
}
void
FGInput::bind ()
{
- // no op
+ // no op
}
void
FGInput::unbind ()
{
- // no op
+ // no op
}
void
FGInput::update ()
{
- // we'll do something here with the joystick
+ // we'll do something here with the joystick
}
void
FGInput::doKey (int k, int modifiers, int x, int y)
{
- float fov, tmp;
- static bool winding_ccw = true;
- int speed;
+ float fov, tmp;
+ static bool winding_ccw = true;
+ int speed;
- SG_LOG(SG_INPUT, SG_INFO, "User pressed key " << k
- << " with modifiers " << modifiers);
+ SG_LOG(SG_INPUT, SG_INFO, "User pressed key " << k
+ << " with modifiers " << modifiers);
- if (_key_bindings[modifiers].find(k) != _key_bindings[modifiers].end()) {
- const vector<FGBinding> &bindings = _key_bindings[modifiers][k];
- for (unsigned int i = 0; i < bindings.size(); i++) {
- bindings[i].fire();
+ if (_key_bindings[modifiers].find(k) != _key_bindings[modifiers].end()) {
+ const vector<FGBinding> &bindings = _key_bindings[modifiers][k];
+ for (unsigned int i = 0; i < bindings.size(); i++) {
+ bindings[i].fire();
+ }
+ return;
}
- return;
- }
- SG_LOG(SG_INPUT, SG_INFO, "(No user binding.)");
+ SG_LOG(SG_INPUT, SG_INFO, "(No user binding.)");
- // Use the old, default actions.
- FGInterface *f = current_aircraft.fdm_state;
- FGViewer *v = globals->get_current_view();
+ // Use the old, default actions.
+ FGInterface *f = current_aircraft.fdm_state;
+ FGViewer *v = globals->get_current_view();
- // everything after here will be removed sooner or later...
+ // everything after here will be removed sooner or later...
- if (modifiers & FG_MOD_SHIFT) {
+ if (modifiers & FG_MOD_SHIFT) {
switch (k) {
case 7: // Ctrl-G key
current_autopilot->set_AltitudeMode(
- FGAutopilot::FG_ALTITUDE_GS1 );
+ FGAutopilot::FG_ALTITUDE_GS1 );
current_autopilot->set_AltitudeEnabled(
- ! current_autopilot->get_AltitudeEnabled()
- );
+ ! current_autopilot->get_AltitudeEnabled()
+ );
return;
case 18: // Ctrl-R key
// temporary
return;
case 19: // Ctrl-S key
current_autopilot->set_AutoThrottleEnabled(
- ! current_autopilot->get_AutoThrottleEnabled()
- );
+ ! current_autopilot->get_AutoThrottleEnabled()
+ );
return;
case 20: // Ctrl-T key
current_autopilot->set_AltitudeMode(
- FGAutopilot::FG_ALTITUDE_TERRAIN );
+ FGAutopilot::FG_ALTITUDE_TERRAIN );
current_autopilot->set_AltitudeEnabled(
- ! current_autopilot->get_AltitudeEnabled()
- );
+ ! current_autopilot->get_AltitudeEnabled()
+ );
return;
case 49: // numeric keypad 1
v->set_goal_view_offset( SGD_PI * 0.75 );
#endif
return;
-// START SPECIALS
+ // START SPECIALS
case 256+GLUT_KEY_F1: {
ifstream input("fgfs.sav");
v->set_goal_view_offset( SGD_PI * 1.75 );
return;
-// END SPECIALS
+ // END SPECIALS
}
ConfirmExitDialog();
return;
-// START SPECIALS
+ // START SPECIALS
case 256+GLUT_KEY_F2: // F2 Reload Tile Cache...
{
if ( global_tile_mgr.init() ) {
// Load the local scenery data
global_tile_mgr.update(
- cur_fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES,
- cur_fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES );
+ cur_fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES,
+ cur_fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES );
} else {
SG_LOG( SG_GENERAL, SG_ALERT,
"Error in Tile Manager initialization!" );
}
BusyCursor(1);
if ( !freeze )
- globals->set_freeze( false );
+ globals->set_freeze( false );
return;
}
case 256+GLUT_KEY_F3: // F3 Take a screen shot
if ( current_autopilot->get_HeadingMode() !=
FGAutopilot::FG_HEADING_WAYPOINT ) {
current_autopilot->set_HeadingMode(
- FGAutopilot::FG_HEADING_WAYPOINT );
+ FGAutopilot::FG_HEADING_WAYPOINT );
current_autopilot->set_HeadingEnabled( true );
} else {
current_autopilot->set_HeadingMode(
- FGAutopilot::FG_TC_HEADING_LOCK );
+ FGAutopilot::FG_TC_HEADING_LOCK );
}
return;
case 256+GLUT_KEY_F8: {// F8 toggles fog ... off fastest nicest...
const string &fog = fgGetString("/sim/rendering/fog");
if (fog == "disabled") {
- fgSetString("/sim/rendering/fog", "fastest");
- SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=fastest");
+ fgSetString("/sim/rendering/fog", "fastest");
+ SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=fastest");
} else if (fog == "fastest") {
- fgSetString("/sim/rendering/fog", "nicest");
- SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=nicest");
+ fgSetString("/sim/rendering/fog", "nicest");
+ SG_LOG(SG_INPUT, SG_INFO, "Fog enabled, hint=nicest");
} else if (fog == "nicest") {
- fgSetString("/sim/rendering/fog", "disabled");
- SG_LOG(SG_INPUT, SG_INFO, "Fog disabled");
+ fgSetString("/sim/rendering/fog", "disabled");
+ SG_LOG(SG_INPUT, SG_INFO, "Fog disabled");
} else {
- fgSetString("/sim/rendering/fog", "disabled");
- SG_LOG(SG_INPUT, SG_ALERT, "Unrecognized fog type "
- << fog << ", changed to 'disabled'");
+ fgSetString("/sim/rendering/fog", "disabled");
+ SG_LOG(SG_INPUT, SG_ALERT, "Unrecognized fog type "
+ << fog << ", changed to 'disabled'");
}
return;
}
return;
}
-// END SPECIALS
+ // END SPECIALS
}
}
void
FGInput::action (const SGPropertyNode * binding)
{
- const string &action = binding->getStringValue("action", "");
- const string &control = binding->getStringValue("control", "");
- bool repeatable = binding->getBoolValue("repeatable", false);
- int step = binding->getIntValue("step", 0.0);
-
- if (control == "") {
- SG_LOG(SG_INPUT, SG_ALERT, "No control specified for key "
- << binding->getIndex());
- return;
- }
-
- else if (action == "") {
- SG_LOG(SG_INPUT, SG_ALERT, "No action specified for key "
- << binding->getIndex());
- return;
- }
-
- else if (action == "switch") {
- fgSetBool(control, !fgGetBool(control));
- }
-
- else if (action == "adjust") {
- const SGValue * step = binding->getValue("step");
- if (step == 0) {
- SG_LOG(SG_INPUT, SG_ALERT, "No step supplied for adjust action for key "
- << binding->getIndex());
- return;
+ const string &action = binding->getStringValue("action", "");
+ const string &control = binding->getStringValue("control", "");
+ bool repeatable = binding->getBoolValue("repeatable", false);
+ int step = binding->getIntValue("step", 0.0);
+
+ if (control == "") {
+ SG_LOG(SG_INPUT, SG_ALERT, "No control specified for key "
+ << binding->getIndex());
+ return;
+ }
+
+ else if (action == "") {
+ SG_LOG(SG_INPUT, SG_ALERT, "No action specified for key "
+ << binding->getIndex());
+ return;
}
- SGValue * target = fgGetValue(control, true);
- // Use the target's type...
- switch (target->getType()) {
- case SGValue::BOOL:
- case SGValue::INT:
- target->setIntValue(target->getIntValue() + step->getIntValue());
- break;
- case SGValue::LONG:
- target->setLongValue(target->getLongValue() + step->getLongValue());
- break;
- case SGValue::FLOAT:
- target->setFloatValue(target->getFloatValue() + step->getFloatValue());
- break;
- case SGValue::DOUBLE:
- case SGValue::UNKNOWN: // treat unknown as a double
- target->setDoubleValue(target->getDoubleValue()
- + step->getDoubleValue());
- break;
- case SGValue::STRING:
- SG_LOG(SG_INPUT, SG_ALERT, "Failed attempt to adjust string property "
- << control);
- break;
+
+ else if (action == "switch") {
+ fgSetBool(control, !fgGetBool(control));
}
- }
-
- else if (action == "assign") {
- const SGValue * value = binding->getValue("value");
- if (value == 0) {
- SG_LOG(SG_INPUT, SG_ALERT, "No value supplied for assign action for key "
- << binding->getIndex());
- return;
+
+ else if (action == "adjust") {
+ const SGValue * step = binding->getValue("step");
+ if (step == 0) {
+ SG_LOG(SG_INPUT, SG_ALERT, "No step supplied for adjust action for key "
+ << binding->getIndex());
+ return;
+ }
+ SGValue * target = fgGetValue(control, true);
+ // Use the target's type...
+ switch (target->getType()) {
+ case SGValue::BOOL:
+ case SGValue::INT:
+ target->setIntValue(target->getIntValue() + step->getIntValue());
+ break;
+ case SGValue::LONG:
+ target->setLongValue(target->getLongValue() + step->getLongValue());
+ break;
+ case SGValue::FLOAT:
+ target->setFloatValue(target->getFloatValue() + step->getFloatValue());
+ break;
+ case SGValue::DOUBLE:
+ case SGValue::UNKNOWN: // treat unknown as a double
+ target->setDoubleValue(target->getDoubleValue()
+ + step->getDoubleValue());
+ break;
+ case SGValue::STRING:
+ SG_LOG(SG_INPUT, SG_ALERT, "Failed attempt to adjust string property "
+ << control);
+ break;
+ }
}
- SGValue * target = fgGetValue(control, true);
- // Use the target's type...
- switch (target->getType()) {
- case SGValue::BOOL:
- target->setBoolValue(value->getBoolValue());
- break;
- case SGValue::INT:
- target->setIntValue(value->getIntValue());
- break;
- case SGValue::LONG:
- target->setLongValue(value->getLongValue());
- break;
- case SGValue::FLOAT:
- target->setFloatValue(value->getFloatValue());
- break;
- case SGValue::DOUBLE:
- target->setDoubleValue(value->getDoubleValue());
- break;
- case SGValue::STRING:
- target->setStringValue(value->getStringValue());
- break;
- case SGValue::UNKNOWN:
- target->setUnknownValue(value->getStringValue());
- break;
+
+ else if (action == "assign") {
+ const SGValue * value = binding->getValue("value");
+ if (value == 0) {
+ SG_LOG(SG_INPUT, SG_ALERT, "No value supplied for assign action for key "
+ << binding->getIndex());
+ return;
+ }
+ SGValue * target = fgGetValue(control, true);
+ // Use the target's type...
+ switch (target->getType()) {
+ case SGValue::BOOL:
+ target->setBoolValue(value->getBoolValue());
+ break;
+ case SGValue::INT:
+ target->setIntValue(value->getIntValue());
+ break;
+ case SGValue::LONG:
+ target->setLongValue(value->getLongValue());
+ break;
+ case SGValue::FLOAT:
+ target->setFloatValue(value->getFloatValue());
+ break;
+ case SGValue::DOUBLE:
+ target->setDoubleValue(value->getDoubleValue());
+ break;
+ case SGValue::STRING:
+ target->setStringValue(value->getStringValue());
+ break;
+ case SGValue::UNKNOWN:
+ target->setUnknownValue(value->getStringValue());
+ break;
+ }
}
- }
- else {
- SG_LOG(SG_INPUT, SG_ALERT, "Unknown action " << action
- << " for key " << binding->getIndex());
- }
+ else {
+ SG_LOG(SG_INPUT, SG_ALERT, "Unknown action " << action
+ << " for key " << binding->getIndex());
+ }
}
#if 0
- FGViewer *v = globals->get_current_view();
+FGViewer *v = globals->get_current_view();
- SG_LOG( SG_INPUT, SG_DEBUG, "Special key hit = " << k );
+SG_LOG( SG_INPUT, SG_DEBUG, "Special key hit = " << k );
- if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
- SG_LOG( SG_INPUT, SG_DEBUG, " SHIFTED" );
- switch (k)
- } else
-}
+if ( GLUT_ACTIVE_SHIFT && glutGetModifiers() ) {
+ SG_LOG( SG_INPUT, SG_DEBUG, " SHIFTED" );
+ switch (k)
+ } else
+ }
#endif
false);
fgTie("/autopilot/locks/wing-leveler", getAPWingLeveler, setAPWingLeveler);
fgTie("/autopilot/locks/nav1", getAPNAV1Lock, setAPNAV1Lock);
+ fgTie("/autopilot/locks/auto-throttle",
+ getAPAutoThrottleLock, setAPAutoThrottleLock);
+ fgTie("/autopilot/control-overrides/rudder",
+ getAPRudderControl, setAPRudderControl);
+ fgTie("/autopilot/control-overrides/elevator",
+ getAPElevatorControl, setAPElevatorControl);
+ fgTie("/autopilot/control-overrides/throttle",
+ getAPThrottleControl, setAPThrottleControl);
// Weather
fgTie("/environment/visibility", getVisibility, setVisibility);
// }
-\f
-////////////////////////////////////////////////////////////////////////
-// Controls
-////////////////////////////////////////////////////////////////////////
-
-#if 0
-
-/**
- * Get the throttle setting, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getThrottle ()
-{
- // FIXME: add engine selector
- return controls.get_throttle(0);
-}
-
-
-/**
- * Set the throttle, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setThrottle (double throttle)
-{
- // FIXME: allow engine selection
- controls.set_throttle(0, throttle);
-}
-
-
-/**
- * Get the fuel mixture setting, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getMixture ()
-{
- // FIXME: add engine selector
- return controls.get_mixture(0);
-}
-
-
-/**
- * Set the fuel mixture, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setMixture (double mixture)
-{
- // FIXME: allow engine selection
- controls.set_mixture(0, mixture);
-}
-
-
-/**
- * Get the propellor pitch setting, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getPropAdvance ()
-{
- // FIXME: add engine selector
- return controls.get_prop_advance(0);
-}
-
-
-/**
- * Set the propellor pitch, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setPropAdvance (double pitch)
-{
- // FIXME: allow engine selection
- controls.set_prop_advance(0, pitch);
-}
-
-
-/**
- * Get the flaps setting, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getFlaps ()
-{
- return controls.get_flaps();
-}
-
-
-/**
- * Set the flaps, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setFlaps (double flaps)
-{
- // FIXME: clamp?
- controls.set_flaps(flaps);
-}
-
-
-/**
- * Get the aileron, from -1.0 (left) to 1.0 (right).
- */
-double
-FGBFI::getAileron ()
-{
- return controls.get_aileron();
-}
-
-
-/**
- * Set the aileron, from -1.0 (left) to 1.0 (right).
- */
-void
-FGBFI::setAileron (double aileron)
-{
- // FIXME: clamp?
- controls.set_aileron(aileron);
-}
-
-
-/**
- * Get the rudder setting, from -1.0 (left) to 1.0 (right).
- */
-double
-FGBFI::getRudder ()
-{
- return controls.get_rudder();
-}
-
-
-/**
- * Set the rudder, from -1.0 (left) to 1.0 (right).
- */
-void
-FGBFI::setRudder (double rudder)
-{
- // FIXME: clamp?
- controls.set_rudder(rudder);
-}
-
-
-/**
- * Get the elevator setting, from -1.0 (down) to 1.0 (up).
- */
-double
-FGBFI::getElevator ()
-{
- return controls.get_elevator();
-}
-
-
-/**
- * Set the elevator, from -1.0 (down) to 1.0 (up).
- */
-void
-FGBFI::setElevator (double elevator)
-{
- // FIXME: clamp?
- controls.set_elevator(elevator);
-}
-
-
-/**
- * Get the elevator trim, from -1.0 (down) to 1.0 (up).
- */
-double
-FGBFI::getElevatorTrim ()
-{
- return controls.get_elevator_trim();
-}
-
-
-/**
- * Set the elevator trim, from -1.0 (down) to 1.0 (up).
- */
-void
-FGBFI::setElevatorTrim (double trim)
-{
- // FIXME: clamp?
- controls.set_elevator_trim(trim);
-}
-
-
-/**
- * Get the highest brake setting, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getBrakes ()
-{
- double b1 = getCenterBrake();
- double b2 = getLeftBrake();
- double b3 = getRightBrake();
- return (b1 > b2 ? (b1 > b3 ? b1 : b3) : (b2 > b3 ? b2 : b3));
-}
-
-
-/**
- * Set all brakes, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setBrakes (double brake)
-{
- setCenterBrake(brake);
- setLeftBrake(brake);
- setRightBrake(brake);
-}
-
-
-/**
- * Get the center brake, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getCenterBrake ()
-{
- return controls.get_brake(2);
-}
-
-
-/**
- * Set the center brake, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setCenterBrake (double brake)
-{
- controls.set_brake(2, brake);
-}
-
-
-/**
- * Get the left brake, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getLeftBrake ()
-{
- return controls.get_brake(0);
-}
-
-
-/**
- * Set the left brake, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setLeftBrake (double brake)
-{
- controls.set_brake(0, brake);
-}
-
-
-/**
- * Get the right brake, from 0.0 (none) to 1.0 (full).
- */
-double
-FGBFI::getRightBrake ()
-{
- return controls.get_brake(1);
-}
-
-
-/**
- * Set the right brake, from 0.0 (none) to 1.0 (full).
- */
-void
-FGBFI::setRightBrake (double brake)
-{
- controls.set_brake(1, brake);
-}
-
-
-#endif
-
\f
////////////////////////////////////////////////////////////////////////
// Autopilot
{
return
(current_autopilot->get_HeadingEnabled() &&
- current_autopilot->get_HeadingMode() == FGAutopilot::FG_DG_HEADING_LOCK);
+ current_autopilot->get_HeadingMode() == DEFAULT_AP_HEADING_LOCK);
}
FGBFI::setAPHeadingLock (bool lock)
{
if (lock) {
- current_autopilot->set_HeadingMode(FGAutopilot::FG_DG_HEADING_LOCK);
+ current_autopilot->set_HeadingMode(DEFAULT_AP_HEADING_LOCK);
current_autopilot->set_HeadingEnabled(true);
} else {
current_autopilot->set_HeadingEnabled(false);
}
}
+/**
+ * Get the autopilot autothrottle lock.
+ */
+bool
+FGBFI::getAPAutoThrottleLock ()
+{
+ return current_autopilot->get_AutoThrottleEnabled();
+}
+
+
+/**
+ * Set the autothrottle lock.
+ */
+void
+FGBFI::setAPAutoThrottleLock (bool lock)
+{
+ current_autopilot->set_AutoThrottleEnabled(lock);
+}
+
+
+// kludge
+double
+FGBFI::getAPRudderControl ()
+{
+ if (getAPHeadingLock())
+ return current_autopilot->get_TargetHeading();
+ else
+ return controls.get_rudder();
+}
+
+// kludge
+void
+FGBFI::setAPRudderControl (double value)
+{
+ if (getAPHeadingLock()) {
+ SG_LOG(SG_GENERAL, SG_DEBUG, "setAPRudderControl " << value );
+ value -= current_autopilot->get_TargetHeading();
+ current_autopilot->HeadingAdjust(value < 0.0 ? -1.0 : 1.0);
+ } else {
+ controls.set_rudder(value);
+ }
+}
+
+// kludge
+double
+FGBFI::getAPElevatorControl ()
+{
+ if (getAPAltitudeLock())
+ return current_autopilot->get_TargetAltitude();
+ else
+ return controls.get_elevator();
+}
+
+// kludge
+void
+FGBFI::setAPElevatorControl (double value)
+{
+ if (getAPAltitudeLock()) {
+ SG_LOG(SG_GENERAL, SG_DEBUG, "setAPElevatorControl " << value );
+ value -= current_autopilot->get_TargetAltitude();
+ current_autopilot->AltitudeAdjust(value < 0.0 ? 100.0 : -100.0);
+ } else {
+ controls.set_elevator(value);
+ }
+}
+
+// kludge
+double
+FGBFI::getAPThrottleControl ()
+{
+ if (getAPAutoThrottleLock())
+ return 0.0; // always resets
+ else
+ return controls.get_throttle(0);
+}
+
+// kludge
+void
+FGBFI::setAPThrottleControl (double value)
+{
+ if (getAPAutoThrottleLock())
+ current_autopilot->AutoThrottleAdjust(value < 0.0 ? -0.01 : 0.01);
+ else
+ controls.set_throttle(0, value);
+}
+
\f
////////////////////////////////////////////////////////////////////////
return current_autopilot->get_TargetLongitude();
}
-#if 0
-/**
- * Set the GPS target longitude in degrees (negative for west).
- */
-void
-FGBFI::setGPSTargetLongitude (double longitude)
-{
- current_autopilot->set_TargetLongitude( longitude );
-}
-#endif
-
\f
////////////////////////////////////////////////////////////////////////