+static bool
+do_press_cockpit_button (const SGPropertyNode *arg)
+{
+ const char *prefix = arg->getStringValue("prefix");
+
+ if (arg->getBoolValue("guarded") && fgGetDouble((string(prefix) + "-guard").c_str()) < 1)
+ return true;
+
+ string prop = string(prefix) + "-button";
+ double value;
+
+ if (arg->getBoolValue("latching"))
+ value = fgGetDouble(prop.c_str()) > 0 ? 0 : 1;
+ else
+ value = 1;
+
+ fgSetDouble(prop.c_str(), value);
+ fgSetBool(arg->getStringValue("discrete"), value > 0);
+
+ return true;
+}
+
+static bool
+do_release_cockpit_button (const SGPropertyNode *arg)
+{
+ const char *prefix = arg->getStringValue("prefix");
+
+ if (arg->getBoolValue("guarded")) {
+ string prop = string(prefix) + "-guard";
+ if (fgGetDouble(prop.c_str()) < 1) {
+ fgSetDouble(prop.c_str(), 1);
+ return true;
+ }
+ }
+
+ if (! arg->getBoolValue("latching")) {
+ fgSetDouble((string(prefix) + "-button").c_str(), 0);
+ fgSetBool(arg->getStringValue("discrete"), false);
+ }
+
+ return true;
+}
+