summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/clientfiles/flightgear/nasal/headtracker.xml
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-03-22 21:48:15 +0100
committerStanislaw Halik <sthalik@misaki.pl>2013-03-22 21:48:15 +0100
commit4f00c4c74d213a37a4b1a3313e50ce2b4dd51271 (patch)
treef692743cb752c994c05fe2761f83af08aa28d239 /facetracknoir/clientfiles/flightgear/nasal/headtracker.xml
parent5c5ec4b4238996770bfd74ddfc87934ace40bf0f (diff)
finish rename
Diffstat (limited to 'facetracknoir/clientfiles/flightgear/nasal/headtracker.xml')
-rw-r--r--facetracknoir/clientfiles/flightgear/nasal/headtracker.xml83
1 files changed, 83 insertions, 0 deletions
diff --git a/facetracknoir/clientfiles/flightgear/nasal/headtracker.xml b/facetracknoir/clientfiles/flightgear/nasal/headtracker.xml
new file mode 100644
index 00000000..d8bd1d0a
--- /dev/null
+++ b/facetracknoir/clientfiles/flightgear/nasal/headtracker.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0"?>
+
+<PropertyList>
+ <nasal>
+ <headtracker>
+ <script>
+ var Value = {
+ new: func(prop) {
+ var m = { parents: [Value] };
+ m.prop = props.globals.getNode(prop, 1);
+ m.value = 0;
+ return m;
+ },
+ apply: func(value) {
+ me.prop.setDoubleValue(me.prop.getValue() - me.value + value);
+ me.value = value;
+ },
+ };
+
+
+ var x = Value.new("/sim/current-view/x-offset-m");
+ var y = Value.new("/sim/current-view/y-offset-m");
+ var z = Value.new("/sim/current-view/z-offset-m");
+ var h = Value.new("/sim/current-view/heading-offset-deg");
+ var p = Value.new("/sim/current-view/pitch-offset-deg");
+ var r = Value.new("/sim/current-view/roll-offset-deg");
+
+
+ var resetting = 0;
+ var status = nil;
+
+ var reset = func {
+ if (status != 1) {
+ setprop("/sim/headtracker/control", 1);
+ resetting = 1;
+ view.resetViewPos();
+ view.resetViewDir();
+ x.value = y.value = z.value = h.value = p.value = r.value = 0;
+ }
+ }
+
+ setlistener("/sim/headtracker/status", func(n) {
+ var s = n.getValue();
+ if (!status and s) {
+ setprop("/sim/headtracker/control", 0);
+ resetting = 0;
+ }
+ status = s;
+ }, 1, 0);
+
+
+ var loop = func {
+ if (!view.index and !resetting) {
+ x.apply(getprop("/sim/headtracker/x-m"));
+ y.apply(getprop("/sim/headtracker/y-m"));
+ z.apply(getprop("/sim/headtracker/z-m"));
+
+ h.apply(getprop("/sim/headtracker/heading-deg"));
+ p.apply(getprop("/sim/headtracker/pitch-deg"));
+ r.apply(-1 * getprop("/sim/headtracker/roll-deg"));
+ }
+ settimer(loop, 0);
+ }
+
+ loop();
+
+ </script>
+ </headtracker>
+ </nasal>
+
+ <sim>
+ <headtracker>
+ <x-m type="double">0</x-m>
+ <y-m type="double">0</y-m>
+ <z-m type="double">0</z-m>
+ <heading-deg type="double">0</heading-deg>
+ <pitch-deg type="double">0</pitch-deg>
+ <roll-deg type="double">0</roll-deg>
+ <status type="int">0</status>
+ <control type="int">0</control>
+ </headtracker>
+ </sim>
+</PropertyList>