2018-02-09 18:55:53 +00:00
|
|
|
# Copyright 2018 Stuart Buchanan
|
|
|
|
# This file is part of FlightGear.
|
|
|
|
#
|
2018-05-28 19:15:57 +00:00
|
|
|
# FlightGear is free software: you can redistribute it and/or modify
|
2018-02-09 18:55:53 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# FlightGear is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
2018-02-04 21:40:37 +00:00
|
|
|
# FG Commands to support simple bindings
|
2018-02-09 15:01:33 +00:00
|
|
|
io.include("Constants.nas");
|
2018-02-04 21:40:37 +00:00
|
|
|
|
|
|
|
removecommand("FG1000HardKeyPushed");
|
|
|
|
addcommand("FG1000HardKeyPushed",
|
|
|
|
func(node) {
|
2019-02-14 22:29:01 +00:00
|
|
|
var device = node.getNode("device", 1).getValue();
|
2018-02-09 15:01:33 +00:00
|
|
|
var name = node.getNode("notification",1).getValue();
|
|
|
|
|
|
|
|
# The knob animation stores the value as an offset property
|
|
|
|
var value = node.getNode("offset", 1).getValue();
|
|
|
|
|
2019-02-14 22:29:01 +00:00
|
|
|
if (name == nil) {
|
|
|
|
print("FG1000HardKeyPushed: No <name> argument passed to fgcommand");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-09 15:01:33 +00:00
|
|
|
if (value == nil) {
|
|
|
|
print("FG1000HardKeyPushed: No <offset> argument passed to fgcommand");
|
|
|
|
return;
|
|
|
|
}
|
2018-02-04 21:40:37 +00:00
|
|
|
|
|
|
|
if (device == nil) {
|
2019-02-14 22:29:01 +00:00
|
|
|
print("FG1000HardKeyPushed: No <device> argument passed to fgcommand for " ~ name);
|
2018-02-04 21:40:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Notification may be provided as a number, or a string.
|
|
|
|
if (int(name) == nil) {
|
|
|
|
# Name is a string, to map it to the correct INT id.
|
2018-02-09 15:01:33 +00:00
|
|
|
if (FASCIA[name] != nil) {
|
|
|
|
name = FASCIA[name];
|
2018-02-04 21:40:37 +00:00
|
|
|
} else {
|
|
|
|
print("Unable to find FASCIA entry for Hard Key " ~ name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
2019-02-14 22:29:01 +00:00
|
|
|
int(device),
|
2018-02-04 21:40:37 +00:00
|
|
|
notifications.PFDEventNotification.HardKeyPushed,
|
|
|
|
{ Id: name, Value: value }
|
|
|
|
);
|
|
|
|
emesary.GlobalTransmitter.NotifyAll(notification);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
removecommand("FG1000SoftKeyPushed");
|
|
|
|
addcommand("FG1000SoftKeyPushed",
|
|
|
|
func(node) {
|
2018-02-09 15:01:33 +00:00
|
|
|
var device = int(node.getNode("device", 1).getValue());
|
|
|
|
var value = node.getNode("offset", 1).getValue();
|
2018-02-04 21:40:37 +00:00
|
|
|
|
|
|
|
if (device == nil) {
|
|
|
|
print("FG1000SoftKeyPushed: Unknown device" ~ node.getNode("device").getValue());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (value == nil) {
|
2018-02-09 15:01:33 +00:00
|
|
|
print("FG1000SoftKeyPushed: No <offset> value for softkey number");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (int(value) == nil) {
|
2018-02-04 21:40:37 +00:00
|
|
|
print("Unable to convert softkey number to integer " ~ node.getNode("value").getValue());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-09 15:01:33 +00:00
|
|
|
value = int(value);
|
|
|
|
|
2018-02-04 21:40:37 +00:00
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
device,
|
|
|
|
notifications.PFDEventNotification.SoftKeyPushed,
|
|
|
|
value
|
|
|
|
);
|
|
|
|
emesary.GlobalTransmitter.NotifyAll(notification);
|
|
|
|
}
|
|
|
|
);
|
2019-02-22 16:32:55 +00:00
|
|
|
|
|
|
|
# This command is a convenience for multi-key/menu support to make it easier to
|
|
|
|
# navigate to particular pages without having to use the FMS knobs.
|
|
|
|
removecommand("FG1000SelectPage");
|
|
|
|
addcommand("FG1000SelectPage",
|
|
|
|
func(node) {
|
|
|
|
var device = node.getNode("device", 1).getValue();
|
|
|
|
var group = node.getNode("group",1).getValue();
|
|
|
|
var page = node.getNode("page",1).getValue();
|
|
|
|
|
|
|
|
if (group == nil) {
|
|
|
|
print("FG1000SelectPage: No <group> argument passed to fgcommand");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page == nil) {
|
|
|
|
print("FG1000SelectPage: No <page> argument passed to fgcommand");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device == nil) {
|
|
|
|
print("FG1000SelectPage: No <device> argument passed to fgcommand for " ~ name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var notification = notifications.PFDEventNotification.new(
|
|
|
|
"MFD",
|
|
|
|
int(device),
|
|
|
|
notifications.PFDEventNotification.SelectPageById,
|
|
|
|
{ Group: group, Page: page }
|
|
|
|
);
|
|
|
|
emesary.GlobalTransmitter.NotifyAll(notification);
|
|
|
|
}
|
|
|
|
);
|