Skip to content

Commit

Permalink
Merge pull request #307 from HHS81/Issue-304
Browse files Browse the repository at this point in the history
Fix #304
  • Loading branch information
HHS81 committed Dec 9, 2018
2 parents f5ce9cf + 774d3be commit 52e5ae8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Nasal/c182s.nas
Expand Up @@ -718,6 +718,28 @@ setlistener("/sim/model/c182s/fog-or-frost-increasing", func (node) {
}, 1, 0);


##########
# Magneto key bindings
# called by pressing { or } (see redefinition in c182-set.xml)
##########
var stepMagnetos = func(p) {
var keypos = getprop("/controls/switches/magnetos");
var magpos = getprop("controls/engines/engine/magnetos");
#print("stepMagnetos called with p=" ~ p ~ "; keypos=" ~ keypos ~ "; magpos=" ~ magpos);

if (p == -1 and keypos <= 3 and keypos > 0) {
# mag decrease
var tgt_value = keypos - 1;
setprop("/controls/switches/magnetos", tgt_value); # triggers an update listener
}
if (p == 1 and keypos < 3 and keypos >= 0) {
# mag increase
var tgt_value = keypos + 1;
setprop("/controls/switches/magnetos", tgt_value); # triggers an update listener
}

}



###########
Expand Down
2 changes: 1 addition & 1 deletion Nasal/engine.nas
Expand Up @@ -280,7 +280,7 @@ var updateMagnetos = func() {
tgt_value = keypos;
}

setprop("controls/engines/engine/magnetos", tgt_value);
setprop("controls/engines/engine/magnetos", tgt_value); # value for internal engine state
#setprop("/engines/engine/magnetos", keypos); # this property seems not to be used!
}
setlistener("/controls/switches/magnetos", updateMagnetos, 1, 1);
Expand Down
31 changes: 31 additions & 0 deletions c182s-set.xml
Expand Up @@ -1082,6 +1082,37 @@
<property>sim/model/hide-yoke</property>
</binding>
</key>


<!-- overwriting { and } default aliases -->
<key n="123">
<name>{</name>
<desc>Decrease Magneto on Selected Engine</desc>
<binding>
<command>nasal</command>
<script>c182s.stepMagnetos(-1)</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>c182s.stepMagnetos(0)</script>
</binding>
</mod-up>
</key>
<key n="125">
<name>}</name>
<desc>Increase Magneto on Selected Engine</desc>
<binding>
<command>nasal</command>
<script>c182s.stepMagnetos(1)</script>
</binding>
<mod-up>
<binding>
<command>nasal</command>
<script>c182s.stepMagnetos(0)</script>
</binding>
</mod-up>
</key>

</keyboard>
</input>
Expand Down

0 comments on commit 52e5ae8

Please sign in to comment.