diff --git a/Input/Joysticks/Saitek/Aviator.xml b/Input/Joysticks/Saitek/Aviator.xml index 4d3febc29..1f0e6b23b 100644 --- a/Input/Joysticks/Saitek/Aviator.xml +++ b/Input/Joysticks/Saitek/Aviator.xml @@ -1,9 +1,8 @@ - @@ -21,18 +20,27 @@ # TM0: All selected; TM1: #1 & #2; TM2: #3 & #4 var engine_axis_mode = 0; # Valid only in TM1 and TM2. - # EA0: throttle, +mod: propeller - # EA1: propeller, +mod: throttle + # EA0: throttle + # EA1: mixture + # EA2: propeller var quick_view_active = 0; var old_view = view.point.save(); var pressed = [0,0,0,0,0,0,0,0,0,0,0,0]; + # Map engines to throttles for TM1 (0, 1) and TM2 (2, 3) var engine = [0, 1, 2, 3]; - # Do per-aircraft modifications - if (getprop("/sim/model/path") == - "Aircraft/Short_Empire/Models/Short_Empire-model.xml") { + # Do per-aircraft modifications + if (contains({"Aircraft/Short_Empire/Models/Short_Empire-model.xml" : 0, + "Aircraft/Lockheed1049/Models/Lockheed1049_twa.xml" : 0}, + getprop("/sim/model/path"))) { + # TM1: the outer engines, TM2: the inner engines engine = [0, 3, 1, 2]; } + if (contains({"Aircraft/DO-X/Models/dox.xml" : 0}, + getprop("/sim/model/path"))) { + engine = [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11], + [0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11]]; + } var goal_heading_offset = @@ -46,7 +54,7 @@ var kbdalt = props.globals.getNode("/devices/status/keyboard/alt", 1); var quick_view = func { - dir = arg[0]; + var dir = arg[0]; if (dir == 0) { quick_view_active = 0; view.point.move(old_view, 0.1); @@ -99,7 +107,13 @@ - + + Stick left/right + + 0 + 0 + 0 + aileron property-scale @@ -111,7 +125,13 @@ - + + Stick forward/back + + 1 + 1 + 1 + elevator property-scale @@ -125,6 +145,7 @@ + Stick twist 3 2 @@ -139,10 +160,18 @@ 1.0 true + + Left throttle 2 3 @@ -155,43 +184,43 @@ if (engine_select_mode == 0) { controls.throttleAxis(); } else { - var val = cmdarg().getNode("setting").getValue(); - var ctrl_pp = - "/controls/engines/engine[" ~ - ((engine_select_mode == 1) ? engine[0] : engine[2]) ~ "]/" ~ - (engine_axis_mode ? "propeller-pitch" : "throttle"); - setprop(ctrl_pp, (1 - val)/2); + controls.perEngineSelectedAxisHandler(engine_axis_mode) + ((engine_select_mode == 1) ? engine[0] : engine[2]); } - - TM0: mixture, +mod: propeller pitch, TM1: throttle/propeller 2, TM2: throttle/propeller 4 + + Right throttle + + 4 + 4 + 4 + + TM0: mixture, TM1: throttle/propeller 2, TM2: throttle/propeller 4 nasal - + + Hat left/right + + 5 + 5 + 5 + quick view left/right, +mod: horizontal view pan true @@ -238,10 +267,12 @@ nasal @@ -249,7 +280,13 @@ - + + Hat up/down + + 6 + 6 + 6 + view reset/quick view front, +mod: vertical view pan true @@ -270,9 +307,11 @@ nasal @@ -296,9 +335,11 @@ nasal @@ -306,8 +347,13 @@ - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/Nasal/controls.nas b/Nasal/controls.nas index 016a35402..2d3f41441 100644 --- a/Nasal/controls.nas +++ b/Nasal/controls.nas @@ -74,6 +74,51 @@ var mixtureAxis = axisHandler("/controls/engines/engine[", "]/mixture"); var propellerAxis = axisHandler("/controls/engines/engine[", "]/propeller-pitch"); var carbHeatAxis = axisHandler("/controls/anti-ice/engine[", "]/carb-heat"); +# Joystick axis handler for controlling subsets of similar properties. +# Shouldn't be called from other contexts. +# The argument engine can be either an index number or a list of +# index numbers. +# Use only when perEngineSelectedAxisHandler() below will not do. +var perIndexAxisHandler = func(pre, post) { + return + func(index, invert = 0) { + var val = cmdarg().getNode("setting").getValue(); + if(invert) val = -val; + if (typeof(index) == "scalar") { + setprop(pre ~ index ~ post, (1 - val) / 2); + } else { + foreach (var e; index) { + setprop(pre ~ e ~ post, (1 - val) / 2); + } + } + }; +} + +# Joystick axis handler for controlling a selected axis on specific engines. +# Shouldn't be called from other contexts. +# The argument mode can be +# 0 - throttle +# 1 - mixture +# 2 - propeller-pitch +# The argument engine to the returned function can be either an +# engine number or a list of engine numbers. +# Usage example (controlling the mixture of engines 1 and 2): +# +var _axisMode = { + 0: perIndexAxisHandler("/controls/engines/engine[", + "]/throttle"), + 1: perIndexAxisHandler("/controls/engines/engine[", + "]/mixture"), + 2: perIndexAxisHandler("/controls/engines/engine[", + "]/propeller-pitch") +}; +var perEngineSelectedAxisHandler = func(mode) { + return _axisMode[mode]; +} + + ## # Wrapper around stepProps() which emulates the "old" flap behavior for # configurations that aren't using the new mechanism.