1
0
Fork 0

Merge branch 'master' of \New Git\fgdata

This commit is contained in:
Vivian Meazza 2010-10-31 09:46:14 +00:00
commit be61cc6e89
3 changed files with 425 additions and 63 deletions

View file

@ -1,9 +1,8 @@
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="joystick.xsl"?>
<!-- $Id$ -->
<!-- Saitek AV8R/Aviator
Copyright (C) 2007 - 2009 Anders Gidenstam (anders(at)gidenstam.org)
Copyright (C) 2007 - 2010 Anders Gidenstam (anders(at)gidenstam.org)
This file is released under the GPL license v2 or later.
-->
<PropertyList>
@ -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 @@
</nasal>
<!-- Analog axis 0. Aileron -->
<axis n="0">
<axis>
<name>Stick left/right</name>
<number>
<unix>0</unix>
<mac>0</mac>
<windows>0</windows>
</number>
<desc>aileron</desc>
<binding>
<command>property-scale</command>
@ -111,7 +125,13 @@
</axis>
<!-- Analog axis 1. Elevator -->
<axis n="1">
<axis>
<name>Stick forward/back</name>
<number>
<unix>1</unix>
<mac>1</mac>
<windows>1</windows>
</number>
<desc>elevator</desc>
<binding>
<command>property-scale</command>
@ -125,6 +145,7 @@
<!-- Analog axis 3. Rudder -->
<axis>
<name>Stick twist</name>
<number>
<unix>3</unix>
<mac>2</mac>
@ -139,10 +160,18 @@
<factor type="double">1.0</factor>
<squared type="bool">true</squared>
</binding>
<!-- binding>
<command>nasal</command>
<script>
setprop("sim/current-view/goal-heading-offset-deg",
-90.0*cmdarg().getNode("setting").getValue());
</script>
</binding -->
</axis>
<!-- Analog axis 2. Throttle 1 -->
<axis>
<name>Left throttle</name>
<number>
<unix>2</unix>
<mac>3</mac>
@ -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]);
}
</script>
</binding>
</axis>
<!-- Analog axis 4. Throttle 2 -->
<axis n="4">
<desc>TM0: mixture, +mod: propeller pitch, TM1: throttle/propeller 2, TM2: throttle/propeller 4</desc>
<axis>
<name>Right throttle</name>
<number>
<unix>4</unix>
<mac>4</mac>
<windows>4</windows>
</number>
<desc>TM0: mixture, TM1: throttle/propeller 2, TM2: throttle/propeller 4</desc>
<binding>
<command>nasal</command>
<script>
if (engine_select_mode == 0) {
if (!modifier) {
controls.mixtureAxis();
} else {
controls.propellerAxis();
}
controls.mixtureAxis();
} else {
var val = cmdarg().getNode("setting").getValue();
var ctrl_pp =
"/controls/engines/engine[" ~
((engine_select_mode == 1) ? engine[1] : engine[3]) ~ "]/" ~
(engine_axis_mode ? "propeller-pitch" : "throttle");
setprop(ctrl_pp, (1 - val)/2);
controls.perEngineSelectedAxisHandler(engine_axis_mode)
((engine_select_mode == 1) ? engine[1] : engine[3]);
}
</script>
</binding>
</axis>
<!-- Axis 5. Hat left/right -->
<axis n="5">
<axis>
<name>Hat left/right</name>
<number>
<unix>5</unix>
<mac>5</mac>
<windows>5</windows>
</number>
<desc>quick view left/right, +mod: horizontal view pan</desc>
<low>
<repeatable type="bool">true</repeatable>
@ -238,10 +267,12 @@
<binding>
<command>nasal</command>
<script>
<![CDATA[
trace("Axis 5, Hat: low released!");
if (!modifier) {
quick_view(0);
}
]]>
</script>
</binding>
</mod-up>
@ -249,7 +280,13 @@
</axis>
<!-- Axis 6. Hat up/down -->
<axis n="6">
<axis>
<name>Hat up/down</name>
<number>
<unix>6</unix>
<mac>6</mac>
<windows>6</windows>
</number>
<desc>view reset/quick view front, +mod: vertical view pan</desc>
<low>
<repeatable type="bool">true</repeatable>
@ -270,9 +307,11 @@
<binding>
<command>nasal</command>
<script>
<![CDATA[
if (!modifier) {
#quick_view(0);
}
]]>
</script>
</binding>
</mod-up>
@ -296,9 +335,11 @@
<binding>
<command>nasal</command>
<script>
<![CDATA[
if (!modifier) {
quick_view(0);
}
]]>
</script>
</binding>
</mod-up>
@ -306,8 +347,13 @@
</axis>
<!-- Trigger Button -->
<button n="0">
<button>
<name>Trigger</name>
<number>
<unix>0</unix>
<mac>0</mac>
<windows>0</windows>
</number>
<desc>function modifier (mod)</desc>
<binding>
<command>nasal</command>
@ -327,8 +373,13 @@
</button>
<!-- Center Button -->
<button n="2">
<button>
<name>Center button</name>
<number>
<unix>2</unix>
<mac>2</mac>
<windows>2</windows>
</number>
<desc>brakes, +mod: Toggle parking brake</desc>
<binding>
<command>nasal</command>
@ -352,8 +403,13 @@
</button>
<!-- Left Button -->
<button n="1">
<button>
<name>Left button</name>
<number>
<unix>1</unix>
<mac>1</mac>
<windows>1</windows>
</number>
<desc>left brake, +mod: PTT</desc>
<binding>
<command>nasal</command>
@ -378,8 +434,13 @@
</button>
<!-- Right Button -->
<button n="3">
<button>
<name>Right button</name>
<number>
<unix>3</unix>
<mac>3</mac>
<windows>3</windows>
</number>
<desc>right brake, +mod: trigger</desc>
<binding>
<command>nasal</command>
@ -404,8 +465,13 @@
</button>
<!-- Button: T1 -->
<button n="4">
<button>
<name>T1</name>
<number>
<unix>4</unix>
<mac>4</mac>
<windows>4</windows>
</number>
<desc>next view, +mod: zoom in +Shift: next weapon</desc>
<repeatable type="bool">true</repeatable>
<binding>
@ -442,8 +508,13 @@
</button>
<!-- Button: T2 -->
<button n="5">
<button>
<name>T2</name>
<number>
<unix>5</unix>
<mac>5</mac>
<windows>5</windows>
</number>
<desc>previous view, +mod: zoom out, +Shift: previous weapon</desc>
<repeatable type="bool">true</repeatable>
<binding>
@ -480,8 +551,13 @@
</button>
<!-- Button: T3 -->
<button n="6">
<button>
<name>T3</name>
<number>
<unix>6</unix>
<mac>6</mac>
<windows>6</windows>
</number>
<desc>trim nose down, +mod: disarm speed brakes</desc>
<repeatable type="bool">true</repeatable>
<binding>
@ -498,8 +574,13 @@
</button>
<!-- Button: T4 -->
<button n="7">
<button>
<name>T4</name>
<number>
<unix>7</unix>
<mac>7</mac>
<windows>7</windows>
</number>
<desc>trim nose up, +mod: deploy speed brakes</desc>
<repeatable type="bool">true</repeatable>
<binding>
@ -516,8 +597,13 @@
</button>
<!-- Button: T5 -->
<button n="8">
<button>
<name>T5</name>
<number>
<unix>8</unix>
<mac>8</mac>
<windows>8</windows>
</number>
<desc>retract flaps one step, +mod: gear up</desc>
<binding>
<command>nasal</command>
@ -542,8 +628,13 @@
</button>
<!-- Button: T6 -->
<button n="9">
<button>
<name>T6</name>
<number>
<unix>9</unix>
<mac>9</mac>
<windows>9</windows>
</number>
<desc>deploy flaps one step, +mod: gear down</desc>
<binding>
<command>nasal</command>
@ -568,8 +659,13 @@
</button>
<!-- Button: T7 -->
<button n="10">
<button>
<name>T7</name>
<number>
<unix>10</unix>
<mac>10</mac>
<windows>10</windows>
</number>
<desc>Increase magnetos, +mod: Engine throttle/propeller axis swap</desc>
<binding>
<command>nasal</command>
@ -578,14 +674,19 @@
if (!modifier) {
controls.stepMagnetos(1);
} else {
engine_axis_mode = !engine_axis_mode;
engine_axis_mode = 2*!engine_axis_mode;
}
</script>
</binding>
</button>
<!-- Button: T8 -->
<button n="11">
<button>
<number>
<unix>11</unix>
<mac>11</mac>
<windows>11</windows>
</number>
<name>T8</name>
<desc>Decrease magnetos, +mod: Engine throttle/propeller axis swap</desc>
<binding>
@ -595,15 +696,20 @@
if (!modifier) {
controls.stepMagnetos(-1);
} else {
engine_axis_mode = !engine_axis_mode;
engine_axis_mode = 2*!engine_axis_mode;
}
</script>
</binding>
</button>
<!-- Button: 3-way Mode switch -->
<button n="12">
<button>
<name>Mode 1</name>
<number>
<unix>12</unix>
<mac>12</mac>
<windows>12</windows>
</number>
<desc>Engine 0/1 throttle mode</desc>
<binding>
<command>nasal</command>
@ -622,7 +728,13 @@
</binding>
</mod-up>
</button>
<button n="13">
<button>
<name>Mode 2</name>
<number>
<unix>13</unix>
<mac>13</mac>
<windows>13</windows>
</number>
<name>Mode 2</name>
<desc>Engine 2/3 throttle mode</desc>
<binding>

View file

@ -1,35 +1,122 @@
<?xml version="1.0"?>
<!-- Saitek Pro Flight Quadrant
Copyright (C) 2008 Ronald Jensen (wino(at)jentronics.com)
This file is released under the GPL license.
Copyright (C) 2008 Ronald Jensen (wino(at)jentronics.com)
Copyright (C) 2009 - 2010 Anders Gidenstam (anders(at)gidenstam.org)
This file is released under the GPL license version 2.
-->
<PropertyList>
<name>Saitek Saitek Pro Flight Quadrant</name>
<name>Saitek Pro Flight Quadrant</name>
<name>Saitek Pro Flight Throttle Quadrant</name>
<axis n="0">
<desc>Throttle</desc>
<nasal>
<script>
<![CDATA[
var self = cmdarg().getParent();
var data = self.getNode("data");
var engine_select_mode = 0;
# TM0: All selected; TM1: #1-#3; TM2: #3-#6
var engine_axis_mode = 0;
# Valid only in TM1 and TM2.
# EA0: throttle
# EA1: mixure
# EA2: propeller
var pressed = [0,0,0,0,0,0];
var engine = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
# 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"))) {
# Map port outer to axis 0, starboard outer to axis 2 and
# the inner engines to axis 1.
engine = [0, [1, 2], 3];
}
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]];
}
if (contains({"Aircraft/Nordstern/Models/Nordstern.xml" : 0},
getprop("/sim/model/path"))) {
engine = [0, 1, [2, 3]];
}
var kbdctrl = props.globals.getNode("/devices/status/keyboard/ctrl", 1);
var kbdalt = props.globals.getNode("/devices/status/keyboard/alt", 1);
var axis_handler = func(axis) {
if (engine_select_mode == 0) {
if (axis == 0) {
controls.throttleAxis();
} elsif (axis == 1) {
controls.propellerAxis();
} elsif (axis == 2) {
controls.mixtureAxis();
}
} else {
controls.perEngineSelectedAxisHandler(engine_axis_mode)
(engine[axis + 3*(engine_select_mode - 1)]);
}
}
var trace = func(str) {
# Uncomment the line below to trace button presses.
#print("Pro-Flight-Quadrant.xml: " ~ str);
}
]]>
</script>
</nasal>
<!-- Levers left to right. -->
<axis>
<name>Left lever</name>
<number>
<unix>0</unix>
<mac>0</mac>
<windows>0</windows>
</number>
<desc>TM0: throttle, TM1: throttle/propeller 1, TM2: throttle/propeller 4</desc>
<binding>
<command>nasal</command>
<script>controls.throttleAxis()</script>
<script>axis_handler(0)</script>
</binding>
</axis>
<axis n="1">
<desc>Prop Pitch</desc>
<axis>
<name>Middle lever</name>
<number>
<unix>1</unix>
<mac>1</mac>
<windows>1</windows>
</number>
<desc>TM0: propeller, TM1: throttle/propeller 2, TM2: throttle/propeller 5</desc>
<binding>
<command>nasal</command>
<script>controls.propellerAxis()</script>
<script>axis_handler(1)</script>
</binding>
</axis>
<axis n="2">
<desc>Mixture </desc>
<axis>
<name>Right lever</name>
<number>
<unix>2</unix>
<mac>2</mac>
<windows>2</windows>
</number>
<desc>TM0: mixture, TM1: throttle/propeller 3, TM2: throttle/propeller 6</desc>
<binding>
<command>nasal</command>
<script>controls.mixtureAxis()</script>
<script>axis_handler(2)</script>
</binding>
</axis>
<button n="0">
<!-- 2-way rocker switches. Left to right. -->
<button>
<name>Left button up</name>
<number>
<unix>0</unix>
<mac>0</mac>
<windows>0</windows>
</number>
<desc>Flaps up</desc>
<repeatable>false</repeatable>
<binding>
@ -42,14 +129,40 @@
<script>controls.flapsDown(0)</script>
</binding>
</mod-up>
<mod-shift>
<binding>
<command>nasal</command>
<script>
trace("Button 0 + shift pressed!");
gui.popupTip("Saitek Quadrant: Throttle Mode 1");
engine_select_mode = 1;
</script>
</binding>
</mod-shift>
</button>
<button n="1">
<name>Left button down</name>
<number>
<unix>1</unix>
<mac>1</mac>
<windows>1</windows>
</number>
<desc>Flaps down</desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script>controls.flapsDown(1)</script>
</binding>
<mod-shift>
<binding>
<command>nasal</command>
<script>
trace("Button 1 + shift pressed!");
gui.popupTip("Saitek Quadrant: Throttle Mode 0");
engine_select_mode = 0;
</script>
</binding>
</mod-shift>
<mod-up>
<binding>
<command>nasal</command>
@ -57,23 +170,64 @@
</binding>
</mod-up>
</button>
<button n="2">
<button>
<name>Middle button up</name>
<number>
<unix>2</unix>
<mac>2</mac>
<windows>2</windows>
</number>
<desc>Elevator trim up</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>controls.elevatorTrim(-0.75)</script>
</binding>
<mod-shift>
<binding>
<command>nasal</command>
<script>
trace("Button 2 + shift pressed!");
if (engine_select_mode) gui.popupTip("Saitek Quadrant: Throttle control");
engine_axis_mode = 0;
</script>
</binding>
</mod-shift>
</button>
<button n="3">
<button>
<name>Middle button down</name>
<number>
<unix>3</unix>
<mac>3</mac>
<windows>3</windows>
</number>
<desc>Elevator trim down</desc>
<repeatable>true</repeatable>
<binding>
<command>nasal</command>
<script>controls.elevatorTrim(0.75)</script>
</binding>
<mod-shift>
<binding>
<command>nasal</command>
<script>
trace("Button 3 + shift pressed!");
if (engine_select_mode)
gui.popupTip("Saitek Quadrant: Propeller control");
engine_axis_mode = 2;
</script>
</binding>
</mod-shift>
</button>
<button n="4">
<button>
<name>Right button up</name>
<number>
<unix>4</unix>
<mac>4</mac>
<windows>4</windows>
</number>
<desc>Gear up</desc>
<repeatable>false</repeatable>
<binding>
@ -81,7 +235,13 @@
<script>controls.gearDown(-1)</script>
</binding>
</button>
<button n="5">
<button>
<name>Right button down</name>
<number>
<unix>5</unix>
<mac>5</mac>
<windows>5</windows>
</number>
<desc>Gear down</desc>
<repeatable>false</repeatable>
<binding>
@ -89,4 +249,49 @@
<script>controls.gearDown(1)</script>
</binding>
</button>
<!-- Axis reverse area switches. -->
<button>
<name>Left lever reverse</name>
<number>
<unix>6</unix>
<mac>6</mac>
<windows>6</windows>
</number>
<desc></desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script></script>
</binding>
</button>
<button>
<name>Middle lever reverse</name>
<number>
<unix>7</unix>
<mac>7</mac>
<windows>7</windows>
</number>
<desc></desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script></script>
</binding>
</button>
<button>
<name>Right lever reverse</name>
<number>
<unix>8</unix>
<mac>8</mac>
<windows>8</windows>
</number>
<desc></desc>
<repeatable>false</repeatable>
<binding>
<command>nasal</command>
<script></script>
</binding>
</button>
</PropertyList>

View file

@ -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):
# <script>
# controls.perEngineSelectedAxisHandler(1)([1,2]);
# </script>
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.