1
0
Fork 0

- move "swap panels" from s-key to S-key

- move "fire starter" from SPACE-key to s-key
- move "open property browser" from Shift-SPACE to Shift-Enter (Shift-Return)
- implement PTT on SPACE/Shift-SPACE  (with the other six SPACE/modifier
  combinations unused, apart from a popup)
- add controls.ptt(v) wrapper function (v can be 1 or 2 for on, and 0 for off)

Easter-Egg:
- pressing the t-key for at least one second resets the warp delta.
  This is an experimental feature that most people won't notice. It's meant
  for investigating if suchlike "unorthodox" key use is acceptable. While
  modifier-keys are the norm on computer keyboards, modifier-times aren't,
  although we are used to them from other devices, such as alarm clocks etc.)
  May later get removed without warning.
This commit is contained in:
mfranz 2007-07-13 13:46:09 +00:00
parent b67402f084
commit 3c08f34027
3 changed files with 121 additions and 33 deletions

View file

@ -327,25 +327,25 @@ rudderTrimAxis = func { rudderTrim(cmdarg().getNode("value").getValue()); }
##
# Gear handling.
#
gearDown = func {
var gearDown = func {
if (arg[0] < 0) {
setprop("/controls/gear/gear-down", 0);
} elsif (arg[0] > 0) {
setprop("/controls/gear/gear-down", 1);
}
}
gearToggle = func { gearDown(getprop("/controls/gear/gear-down") > 0 ? -1 : 1); }
var gearToggle = func { gearDown(getprop("/controls/gear/gear-down") > 0 ? -1 : 1); }
##
# Brake handling.
#
fullBrakeTime = 0.5;
applyBrakes = func(v, which = 0) {
var fullBrakeTime = 0.5;
var applyBrakes = func(v, which = 0) {
if (which <= 0) { interpolate("/controls/gear/brake-left", v, fullBrakeTime); }
if (which >= 0) { interpolate("/controls/gear/brake-right", v, fullBrakeTime); }
}
applyParkingBrake = func(v) {
var applyParkingBrake = func(v) {
if (!v) { return; }
var p = "/controls/gear/brake-parking";
setprop(p, var i = !getprop(p));
@ -355,11 +355,16 @@ applyParkingBrake = func(v) {
##
# Weapon handling.
#
trigger = func(b) { setprop("/controls/armament/trigger", b); }
weaponSelect = func(d) {
var trigger = func(b) setprop("/controls/armament/trigger", b);
var weaponSelect = func(d) {
var ws = props.globals.getNode("/controls/armament/selected", 1);
var n = ws.getValue();
if (n == nil) { n = 0; }
ws.setIntValue(n + d);
}
##
# Communication.
#
var ptt = func(b) setprop("/instrumentation/comm/ptt", b);

View file

@ -821,7 +821,7 @@ debug_keys = {
{ name : "Shift-F3", desc : "load panel" },
{ name : "Shift-F4", desc : "reload global preferences" },
{ name : "Shift-F9", desc : "toggle FDM data logging" },
{ name : "Shift-Space", desc : "open property browser" },
{ name : "Shift-Enter", desc : "open property browser" },
],
};
@ -869,7 +869,7 @@ common_aircraft_keys = {
{ name : "7/Home", desc : "increase elevator trim" },
{ name : "8/Down", desc : "decrease elevator or AP altitude" },
{ name : "9/PgUp", desc : "incr. throttle or AP autothrottle" },
{ name : "Space", desc : "fire starter on selected eng." },
{ name : "Space", desc : "PTT - Push To Talk (via VoIP)" },
{ name : "!/@/#/$", desc : "select engine 1/2/3/4" },
{ name : "b", desc : "apply all brakes" },
{ name : "B", desc : "toggle parking brake" },
@ -884,7 +884,8 @@ common_aircraft_keys = {
{ name : "m/M", desc : "mixture richer/leaner" },
{ name : "n/N", desc : "propeller finer/coarser" },
{ name : "P", desc : "toggle 2D panel" },
{ name : "s", desc : "swap panels" },
{ name : "S", desc : "swap panels" },
{ name : "s", desc : "fire starter on selected eng." },
{ name : ", .", desc : "left/right brake (comma, period)" },
{ name : "~", desc : "select all engines (tilde)" },
{ name : "[ ]", desc : "flaps up/down" },

View file

@ -2,8 +2,7 @@
<!--
Key binding definitions.
The list here is not yet comprehensive: a few of the bindings are
still handled in the C++ code.
The *-key in fg/osg/osgviewer is handled in the C++ code.
Regular keycodes go up to 255; special keys start at 256, and can be
calculated by adding 256 to the GLUT key value in glut.h.
@ -11,6 +10,32 @@ calculated by adding 256 to the GLUT key value in glut.h.
<PropertyList>
<nasal>
<script>
var kbdshift = props.globals.getNode("/devices/status/keyboard/shift");
var kbdctrl = props.globals.getNode("/devices/status/keyboard/ctrl");
var kbdalt = props.globals.getNode("/devices/status/keyboard/alt");
var get_modifiers = func {
kbdshift.getValue() + 2 * kbdctrl.getValue() + 4 * kbdalt.getValue();
}
var space_release = func {}
var space = func(state, mod) {
if (!state) {
space_release();
return space_release = func {}
}
if (mod == 0 or mod == 1) {
controls.ptt(mod + 1);
space_release = func { controls.ptt(0) }
} else {
gui.popupTip("SPACE " ~ mod ~ " " ~ (state ? "press" : "release"));
}
}
</script>
</nasal>
<key n="1">
<name>Ctrl-A</name>
<desc>Toggle autopilot altitude lock.</desc>
@ -95,6 +120,12 @@ calculated by adding 256 to the GLUT key value in glut.h.
<property>/controls/flight/rudder</property>
<step type="double">0.05</step>
</binding>
<mod-shift>
<binding>
<command>nasal</command>
<script>gui.property_browser()</script>
</binding>
</mod-shift>
</key>
<key n="14">
@ -242,22 +273,28 @@ calculated by adding 256 to the GLUT key value in glut.h.
<key n="32">
<name>SPACE</name>
<desc>Fire Starter on Selected Engine(s)</desc>
<desc>PTT - Push To Talk (via VoIP)</desc>
<binding>
<command>nasal</command>
<script>controls.startEngine()</script>
<script>space(1, get_modifiers())</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>props.setAll("/controls/engines/engine", "starter", 0)</script>
<script>space(0, get_modifiers())</script>
</binding>
</mod-up>
<mod-shift>
<binding>
<command>nasal</command>
<script>gui.property_browser()</script>
<script>space(1, get_modifiers())</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>space(0, get_modifiers())</script>
</binding>
</mod-up>
</mod-shift>
</key>
@ -619,6 +656,29 @@ calculated by adding 256 to the GLUT key value in glut.h.
</binding>
</key>
<key n="83">
<name>S</name>
<desc>Swap panels.</desc>
<binding>
<condition>
<not>
<property>/sim/allow-toggle-cockpit</property>
</not>
</condition>
<command>property-swap</command>
<property>/sim/panel/path</property>
<property>/sim/panel_2/path</property>
</binding>
<binding>
<condition>
<not>
<property>/sim/allow-toggle-cockpit</property>
</not>
</condition>
<command>panel-load</command>
</binding>
</key>
<key n="84">
<name>T</name>
<desc>Decrease warp delta.</desc>
@ -856,27 +916,31 @@ calculated by adding 256 to the GLUT key value in glut.h.
<key n="115">
<name>s</name>
<desc>Swap panels.</desc>
<desc>Fire Starter on Selected Engine(s)</desc>
<binding>
<condition>
<not>
<property>/sim/allow-toggle-cockpit</property>
</not>
</condition>
<command>property-swap</command>
<property>/sim/panel/path</property>
<property>/sim/panel_2/path</property>
</binding>
<binding>
<condition>
<not>
<property>/sim/allow-toggle-cockpit</property>
</not>
</condition>
<command>panel-load</command>
<command>nasal</command>
<script>controls.startEngine()</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>props.setAll("/controls/engines/engine", "starter", 0)</script>
</binding>
</mod-up>
<mod-shift>
<binding>
<command>nasal</command>
<script>gui.property_browser()</script>
</binding>
</mod-shift>
</key>
<nasal>
<script>
t_id = 0;
</script>
</nasal>
<key n="116">
<name>t</name>
<desc>Increase warp delta.</desc>
@ -885,6 +949,24 @@ calculated by adding 256 to the GLUT key value in glut.h.
<property>/sim/time/warp-delta</property>
<step type="int">30</step>
</binding>
<binding>
<command>nasal</command>
<script>
(func(x) {
settimer(func {
x == t_id or return;
gui.popupTip("resetting warp");
setprop("/sim/time/warp-delta", 0);
}, 1, 1)
})(t_id += 1)
</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>t_id += 1</script>
</binding>
</mod-up>
</key>
<key n="118">