Hi all!

Currently the joystick throttle axis and the mouse throttle control apply any throttle change to all engines. In my work on LZ-129 Hindenburg I discovered that I need to be able to quickly control the engines individually or in (sub)groups - and I think this ability would be useful also for other multi-engine aircraft.

I propose the following changes to controls.nas:

1. throttleMouse(), throttleAxis() and incThrottle() only change the
   throttle setting for the selected engines, i.e. those that have
   /sim/input/selected/engine[i] == true

2. A new function controls.selectEngineToo(e_no) adds engine number e_no
   to the set of active engines. The existing selectEngine() is mutually
   exclusive - it deselects all other engines. (I hope somebody can come
   up with a better name than selectEngineToo..)

3. Mixture and propeller controls seem to honour engine selection already.


On my system I have mapped controls.selectEngineToo(<number>) to
shift+ctrl+<number>, which I find convenient and easy to work with.
E.g. shift+1 and then shift+ctrl+2 selects engine 1 and 2.
Aircraft like Dornier Do X or Convair B-36 could add their own keyboard shortcuts to select engine groups.. :)


Here is a patch for Nasal/controls.nas that implements the changes:

http://www.gidenstam.org/FlightGear/misc/controls.nas_individual_throttles.diff


Suggestions and comments are welcome!

Cheers,

Anders
--
---------------------------------------------------------------------------
Anders Gidenstam
mail: anders(at)gidenstam.org
WWW: http://www.gidenstam.org/FlightGear/JSBSim-LTA/
Index: Nasal/controls.nas
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Nasal/controls.nas,v
retrieving revision 1.21
diff -u -p -u -r1.21 controls.nas
--- Nasal/controls.nas  22 Jun 2007 18:49:38 -0000      1.21
+++ Nasal/controls.nas  6 Jul 2007 22:31:28 -0000
@@ -27,6 +27,10 @@ selectEngine = func {
     foreach(node; sel) { node.setBoolValue(node.getIndex() == arg[0]); }
 }
 
+selectEngineToo = func {
+    setprop("/sim/input/selected/engine["~arg[0]~"]", 1);
+}
+
 selectAllEngines = func {
     sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
     foreach(node; sel) { node.setBoolValue(1); }
@@ -53,10 +57,16 @@ centerFlightControls = func {
 
 throttleMouse = func {
     if(!getprop("/devices/status/mice/mouse[0]/button[1]")) { return; }
-    val = (cmdarg().getNode("offset").getValue() * -4
-           + getprop("/controls/engines/engine/throttle"));
-    if(size(arg) > 0) { val = -val; }
-    props.setAll("/controls/engines/engine", "throttle", val);
+    sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
+    foreach(node; sel) {
+      if (node.getValue()) {
+        val = (cmdarg().getNode("offset").getValue() * -4 +
+          getprop("/controls/engines/engine["~node.getIndex()~"]/throttle"));
+        if(size(arg) > 0) { val = -val; }
+        setprop("/controls/engines/engine["~node.getIndex()~"]/throttle",
+                val);
+      }
+    }
 }
 
 # Joystick axis handlers (uses cmdarg).  Shouldn't be called from
@@ -64,7 +74,13 @@ throttleMouse = func {
 throttleAxis = func {
     val = cmdarg().getNode("setting").getValue();
     if(size(arg) > 0) { val = -val; }
-    props.setAll("/controls/engines/engine", "throttle", (1 - val)/2);
+    sel = props.globals.getNode("/sim/input/selected").getChildren("engine");
+    foreach(node; sel) {
+        if (node.getValue()) {
+            setprop("/controls/engines/engine["~node.getIndex()~"]/throttle",
+                    (1 - val)/2);
+        }
+    }
 }
 mixtureAxis = func {
     val = cmdarg().getNode("setting").getValue();
@@ -218,16 +234,19 @@ adjEngControl = func {
 # arg[1] is the auto-throttle target speed increment
 incThrottle = func {
     auto = props.globals.getNode("/autopilot/locks/speed", 1);
+    selected = props.globals.getNode("/sim/input/selected");
     if ( !auto.getValue() ) {
       engs = props.globals.getNode("/controls/engines").getChildren("engine");
       foreach(e; engs) {
-        node = e.getNode("throttle", 1);
-        node.setValue(node.getValue() + arg[0]);
-        if ( node.getValue() < -1.0 ) {
-          node.setValue( -1.0 );
-        }
-        if ( node.getValue() > 1.0 ) {
-          node.setValue( 1.0 );
+        if(selected.getChild("engine", e.getIndex(), 1).getBoolValue()) {
+          node = e.getNode("throttle", 1);
+          node.setValue(node.getValue() + arg[0]);
+          if ( node.getValue() < -1.0 ) {
+            node.setValue( -1.0 );
+          }
+          if ( node.getValue() > 1.0 ) {
+            node.setValue( 1.0 );
+          }
         }
       }
     } else {
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to