Debian Codegraph @

Input/Joysticks/ThrustMaster/Warthog/Stick/stick_rotate.xml

raw symbols SCIP
1 <?xml version="1.0"?>
2 <!--
3 Overlay that rotates the stick angle.
4 Copyright (c) 2011 Melchior FRANZ mfranz # aon : at
5
6 Usage: fgfs ~~prop:input/joysticks/overlays=stick_rotate ~~prop:d:input/joysticks/stick-angle=15
7 -->
8
9 <PropertyList>
10 <nasal>
11 <script>
12 contains(caller(0)[0], "stick") and removelistener(stick.listener);
13
14 var stick = {
15 init: func {
16 me.x = me.y = 0;
17 var a = props.globals.initNode("/input/joysticks/stick-angle");
18 me.listener = setlistener(a, func(n) {
19 me.angle = n.getValue() * D2R;
20 me.sin = math.sin(me.angle);
21 me.cos = math.cos(me.angle);
22 }, 1);
23 },
24 value: func cmdarg().getNode("setting").getValue(),
25 setx: func {
26 me.x = me.value();
27 me.update();
28 },
29 sety: func {
30 me.y = -me.value();
31 me.update();
32 },
33 update: func {
34 setprop("/controls/flight/aileron", me.x * me.cos + me.y * me.sin);
35 setprop("/controls/flight/elevator", me.y * me.cos - me.x * me.sin);
36 },
37 };
38
39 stick.init();
40 </script>
41 </nasal>
42
43 <axis n="0">
44 <tolerance>0.00001</tolerance>
45 <binding>
46 <command>nasal</command>
47 <script>stick.setx()</script>
48 </binding>
49 </axis>
50
51 <axis n="1">
52 <tolerance>0.00001</tolerance>
53 <binding>
54 <command>nasal</command>
55 <script>stick.sety()</script>
56 </binding>
57 </axis>
58 </PropertyList>