Showing 1 changed files with 322 additions and 313 deletions
+322 -313
.fgfs/Input/Joysticks/T-Flight-Stick-X.xml
... ...
@@ -1,313 +1,322 @@
1
-<?xml version="1.0"?>
2
-
3
-<PropertyList>
4
-  <nasal>
5
-    <script><![CDATA[
6
-      var skipFlightControls = props.globals.getNode("/sim/mouse/skip-flight-controls-mode");
7
-      setlistener("/sim/signals/fdm-initilized", func {
8
-          skipFlightControls.setBoolValue(1);
9
-          print("JOYSTICK set mouse flight control OFF: ", skipFlightControls.getValue());
10
-      }, 1 );
11
-      setlistener("/sim/signals/save", func {
12
-          skipFlightControls.setBoolValue(0);
13
-          print("JOYSTICK save mouse flight control ON: ", skipFlightControls.getValue());
14
-      } );
15
-
16
-      # determine Nasal namespace for this joystick
17
-      # stored in js[0]
18
-      string.scanf(cmdarg().getNode("module").getValue(), "__js%u", var js = []);
19
-
20
-      # array with prop path for each button status
21
-      var pressed_button = [];
22
-      for (var i = 0; i < 12; i += 1)
23
-        append(pressed_button, "/devices/status/joysticks/joystick[" ~ js[0] ~ "]/button[" ~ i ~ "]");
24
-
25
-      var previousMouseMode = 0;
26
-      var swap_views = 
27
-
28
-      var chinese_hat = func (heading, pitch) {
29
-        if (getprop(pressed_button[0])) {
30
-          if    (pitch   > 0) view.decrease();
31
-          elsif (pitch   < 0) view.increase();
32
-          elsif (heading > 0){view.resetViewDir();view.resetFOV();}
33
-          elsif (heading < 0) view.resetFOV();
34
-        }
35
-        elsif (getprop(pressed_button[10])) {
36
-          if (pitch)
37
-            controls.elevatorTrim(pitch);
38
-          else
39
-            controls.rudderTrim(heading);
40
-        }
41
-        elsif (getprop(pressed_button[11]) and heading) {
42
-          controls.aileronTrim(heading);
43
-        }
44
-        else {
45
-          if (heading) {
46
-            fgcommand("property-adjust", {
47
-              property : "/sim/current-view/goal-heading-offset-deg",
48
-              step : 2.0 * heading
49
-            });
50
-          }
51
-          elsif (pitch) {
52
-            fgcommand("property-adjust", {
53
-              property : "/sim/current-view/goal-pitch-offset-deg",
54
-              step : 2.0 * pitch
55
-            });
56
-          }
57
-        }
58
-      }
59
-
60
-      var addSelectedEngine = func (i) {
61
-        var toAdd = [ i ];
62
-        foreach(var e; controls.engines)
63
-          if (e.selected.getValue() and e.index != i)
64
-            append(toAdd, e.index);
65
-        controls.selectEngines(1, toAdd);
66
-        printf("engine %d added to joystick controls", i);
67
-        gui.popupTip("engine " ~ i ~ " joystick controlled");
68
-      }
69
-
70
-      var removeSelectedEngine = func (i) {
71
-        var toRemove = [ i ];
72
-        foreach(var e; controls.engines)
73
-          if (!(e.selected.getValue() and e.index == i))
74
-            append(toRemove, e.index);
75
-        controls.selectEngines(0, toRemove);
76
-        printf("engine %d removed from joystick controls", i);
77
-        gui.popupTip("engine " ~ i ~ " joystick uncontrolled");
78
-      }
79
-     
80
-      # key = button identifier as displayed on joystick
81
-      joystick_button = {
82
-        2 : func (pressed) {
83
-          if (pressed) {
84
-            if (getprop("/sim/current-view/view-number") > 1)
85
-              return;
86
-            previousMouseMode = getprop("/devices/status/mice/mouse[0]/mode");
87
-            setprop("/devices/status/mice/mouse[0]/mode", 2);
88
-          }
89
-          elsif (getprop(pressed_button[0]))
90
-            return;
91
-          else
92
-            setprop("/devices/status/mice/mouse[0]/mode", previousMouseMode);
93
-          setprop("/sim/current-view/view-number", pressed);
94
-        },
95
-
96
-        3 : func (pressed) {
97
-          controls.applyBrakes(pressed)
98
-        },
99
-
100
-        4 : func {
101
-        },
102
-
103
-        5 : func {
104
-          controls.flapsDown(1)
105
-        },
106
-
107
-        6 : func {
108
-          controls.flapsDown(-1)
109
-        },
110
-
111
-        7 : func {
112
-          if    (getprop(pressed_button[10])) addSelectedEngine(2);
113
-          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
114
-          else controls.adjMixture(1);
115
-        },
116
-
117
-        8 : func {
118
-          if    (getprop(pressed_button[10])) addSelectedEngine(3);
119
-          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
120
-          else controls.adjMixture(-1);
121
-        },
122
-
123
-        9 : func {
124
-          if    (getprop(pressed_button[10])) addSelectedEngine(1);
125
-          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
126
-          else controls.adjPropeller(1);
127
-        },
128
-
129
-        10 : func {
130
-          if    (getprop(pressed_button[10])) addSelectedEngine(0);
131
-          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
132
-          else controls.adjPropeller(-1);
133
-        },
134
-      }
135
-    ]]></script>
136
-  </nasal>
137
-
138
-  <name type="string">T.Flight Stick X</name>
139
-  <name type="string">Thrustmaster T.Flight Stick X</name>
140
-
141
-  <axis n="0">
142
-    <desc>Aileron</desc>
143
-    <binding>
144
-      <command>property-scale</command>
145
-      <property>/controls/flight/aileron</property>
146
-      <squared type="bool">true</squared>
147
-    </binding>
148
-  </axis>
149
-
150
-  <axis n="1">
151
-    <desc>Elevator</desc>
152
-    <binding>
153
-      <command>property-scale</command>
154
-      <property>/controls/flight/elevator</property>
155
-      <factor type="double">-1.0</factor>
156
-      <squared type="bool">true</squared>
157
-    </binding>
158
-  </axis>
159
-
160
-  <axis>
161
-    <number>
162
-      <windows>2</windows>
163
-      <unix>3</unix>
164
-    </number>
165
-    <desc>Increase/Reduce Throttle</desc>
166
-    <binding>
167
-      <command>nasal</command>
168
-      <script>controls.throttleAxis()</script>
169
-    </binding>
170
-  </axis>
171
-
172
-  <axis>
173
-    <number>
174
-      <windows>3</windows>
175
-      <unix>2</unix>
176
-    </number>
177
-    <desc>Rudder Left/Right</desc>
178
-    <binding>
179
-      <command>property-scale</command>
180
-      <property>/controls/flight/rudder</property>
181
-      <factor type="double">1.0</factor>
182
-    </binding>
183
-  </axis>
184
-
185
-  <axis>
186
-    <number>
187
-      <windows>6</windows>
188
-      <unix>4</unix>
189
-    </number>
190
-    <desc>View Direction | reset FoV | reset view direction</desc>
191
-    <low>
192
-      <repeatable>true</repeatable>
193
-      <binding>
194
-        <command>nasal</command>
195
-        <script>chinese_hat(1, 0)</script>
196
-      </binding>
197
-    </low>
198
-    <high>
199
-      <repeatable>true</repeatable>
200
-      <binding>
201
-        <command>nasal</command>
202
-        <script>chinese_hat(-1, 0)</script>
203
-      </binding>
204
-    </high>
205
-  </axis>
206
-
207
-  <axis>
208
-    <number>
209
-      <windows>7</windows>
210
-      <unix>5</unix>
211
-    </number>
212
-    <desc>Orientation up or down / Increase or decrease FoV</desc>
213
-    <low>
214
-      <repeatable>true</repeatable>
215
-      <binding>
216
-        <command>nasal</command>
217
-        <script>chinese_hat(0, 1)</script>
218
-      </binding>
219
-    </low>
220
-    <high>
221
-      <repeatable>true</repeatable>
222
-      <binding>
223
-        <command>nasal</command>
224
-        <script>chinese_hat(0, -1)</script>
225
-      </binding>
226
-    </high>
227
-  </axis>
228
-
229
-  <button n="1">
230
-    <desc>Swap first and second views</desc>
231
-    <binding>
232
-      <command>nasal</command>
233
-      <script>joystick_button[2](1)</script>
234
-    </binding>
235
-    <mod-up>
236
-      <binding>
237
-        <command>nasal</command>
238
-        <script>joystick_button[2](0)</script>
239
-      </binding>
240
-    </mod-up>
241
-  </button>
242
-
243
-  <button n="2">
244
-    <desc>Apply brakes</desc>
245
-    <binding>
246
-      <command>nasal</command>
247
-      <script>joystick_button[3](0)</script>
248
-    </binding>
249
-    <mod-up>
250
-      <binding>
251
-        <command>nasal</command>
252
-        <script>joystick_button[3](1)</script>
253
-      </binding>
254
-    </mod-up>
255
-  </button>
256
-
257
-  <button n="4">
258
-    <desc>Extend Flaps Incrementally</desc>
259
-    <repeatable>false</repeatable>
260
-    <binding>
261
-      <command>nasal</command>
262
-      <script>joystick_button[5]()</script>
263
-    </binding>
264
-  </button>
265
-
266
-  <button n="5">
267
-    <desc>Retract Flaps Incrementally</desc>
268
-    <repeatable>false</repeatable>
269
-    <binding>
270
-      <command>nasal</command>
271
-      <script>joystick_button[6]()</script>
272
-    </binding>
273
-  </button>
274
-
275
-  <button n="6">
276
-    <desc>Handle mixture | add or remove engine 0</desc>
277
-    <repeatable>true</repeatable>
278
-    <binding>
279
-      <command>nasal</command>
280
-      <script>joystick_button[7]()</script>
281
-    </binding>
282
-  </button>
283
-
284
-  <button n="7">
285
-    <desc>Handle mixture | add or remove engine 1</desc>
286
-    <repeatable>true</repeatable>
287
-    <binding>
288
-      <command>nasal</command>
289
-      <script>joystick_button[8]()</script>
290
-    </binding>
291
-  </button>
292
-
293
-  <button n="8">
294
-    <desc>Handle mixture | add or remove engine 2</desc>
295
-    <repeatable>true</repeatable>
296
-    <binding>
297
-      <command>nasal</command>
298
-      <script>joystick_button[9]()</script>
299
-    </binding>
300
-  </button>
301
-
302
-  <button n="9">
303
-    <desc>Handle mixture | add or remove engine 3</desc>
304
-    <repeatable>true</repeatable>
305
-    <binding>
306
-      <command>nasal</command>
307
-      <script>joystick_button[10]()</script>
308
-    </binding>
309
-  </button>
310
-
311
-</PropertyList>
312
-
313
-<!-- end of T.Flight Stick X.xml -->
1
+<?xml version="1.0"?>
2
+
3
+<PropertyList>
4
+  <nasal>
5
+    <script><![CDATA[
6
+      var skipFlightControls = props.globals.getNode("/sim/mouse/skip-flight-controls-mode");
7
+      setlistener("/sim/signals/fdm-initilized", func {
8
+          skipFlightControls.setBoolValue(1);
9
+          print("JOYSTICK set mouse flight control OFF: ", skipFlightControls.getValue());
10
+      }, 1 );
11
+      setlistener("/sim/signals/save", func {
12
+          skipFlightControls.setBoolValue(0);
13
+          print("JOYSTICK save mouse flight control ON: ", skipFlightControls.getValue());
14
+      } );
15
+
16
+      # determine Nasal namespace for this joystick
17
+      # stored in js[0]
18
+      string.scanf(cmdarg().getNode("module").getValue(), "__js%u", var js = []);
19
+
20
+      # array with prop path for each button status
21
+      var pressed_button = [];
22
+      for (var i = 0; i < 12; i += 1)
23
+        append(pressed_button, "/devices/status/joysticks/joystick[" ~ js[0] ~ "]/button[" ~ i ~ "]");
24
+
25
+      var previousMouseMode = 0;
26
+      var locked_view = 0;
27
+
28
+      var chinese_hat = func (heading, pitch) {
29
+        if (getprop(pressed_button[0])) {
30
+          if    (pitch   > 0) view.decrease();
31
+          elsif (pitch   < 0) view.increase();
32
+          elsif (heading > 0){view.resetViewDir();view.resetFOV();}
33
+          elsif (heading < 0) view.resetFOV();
34
+        }
35
+        elsif (getprop(pressed_button[10])) {
36
+          if (pitch)
37
+            controls.elevatorTrim(pitch);
38
+          else
39
+            controls.rudderTrim(heading);
40
+        }
41
+        elsif (getprop(pressed_button[11]) and heading) {
42
+          controls.aileronTrim(heading);
43
+        }
44
+        else {
45
+          if (heading) {
46
+            fgcommand("property-adjust", {
47
+              property : "/sim/current-view/goal-heading-offset-deg",
48
+              step : 2.0 * heading
49
+            });
50
+          }
51
+          elsif (pitch) {
52
+            fgcommand("property-adjust", {
53
+              property : "/sim/current-view/goal-pitch-offset-deg",
54
+              step : 2.0 * pitch
55
+            });
56
+          }
57
+        }
58
+      }
59
+
60
+      var addSelectedEngine = func (i) {
61
+        controls.engines[i].selected.setBoolValue(1);
62
+        printf("engine %d added to joystick controls", i);
63
+        gui.popupTip("engine " ~ i ~ " joystick controlled");
64
+      }
65
+
66
+      var removeSelectedEngine = func (i) {
67
+        controls.engines[i].selected.setBoolValue(0);
68
+        printf("engine %d removed from joystick controls", i);
69
+        gui.popupTip("engine " ~ i ~ " joystick uncontrolled");
70
+      }
71
+
72
+      # key = button identifier as displayed on joystick
73
+      joystick_button = {
74
+        2 : func (pressed) {
75
+          if (pressed) {
76
+            if (getprop("/sim/current-view/view-number") > 1 or locked_view)
77
+              return;
78
+            previousMouseMode = getprop("/devices/status/mice/mouse[0]/mode");
79
+            setprop("/devices/status/mice/mouse[0]/mode", 2);
80
+          }
81
+          elsif (getprop(pressed_button[0])) {
82
+            locked_view = 1;
83
+            return;
84
+          }
85
+          else {
86
+            locked_view = 0;
87
+            setprop("/devices/status/mice/mouse[0]/mode", previousMouseMode);
88
+          }
89
+          setprop("/sim/current-view/view-number", pressed);
90
+        },
91
+
92
+        3 : func (pressed) {
93
+          controls.applyBrakes(pressed)
94
+        },
95
+
96
+        4 : func {
97
+        },
98
+
99
+        5 : func {
100
+          controls.flapsDown(1)
101
+        },
102
+
103
+        6 : func {
104
+          if    (getprop(pressed_button[10])) {
105
+            for (var i = 0; i < 4; i += 1)
106
+              controls.engines[i].selected.setBoolValue(1);
107
+            printf("all engines added to joystick controls");
108
+            gui.popupTip("joystick controls all engines");
109
+          }
110
+          elsif (getprop(pressed_button[11])) {
111
+            for (var i = 0; i < 4; i += 1)
112
+              controls.engines[i].selected.setBoolValue(0);
113
+            printf("joystick controls no engines", i);
114
+            gui.popupTip("joystick controls no engine");
115
+          }
116
+          else
117
+            controls.flapsDown(-1)
118
+        },
119
+
120
+        7 : func {
121
+          if    (getprop(pressed_button[10])) addSelectedEngine(2);
122
+          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
123
+          else controls.adjMixture(1);
124
+        },
125
+
126
+        8 : func {
127
+          if    (getprop(pressed_button[10])) addSelectedEngine(3);
128
+          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
129
+          else controls.adjMixture(-1);
130
+        },
131
+
132
+        9 : func {
133
+          if    (getprop(pressed_button[10])) addSelectedEngine(1);
134
+          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
135
+          else controls.adjPropeller(1);
136
+        },
137
+
138
+        10 : func {
139
+          if    (getprop(pressed_button[10])) addSelectedEngine(0);
140
+          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
141
+          else controls.adjPropeller(-1);
142
+        },
143
+      }
144
+    ]]></script>
145
+  </nasal>
146
+
147
+  <name type="string">T.Flight Stick X</name>
148
+  <name type="string">Thrustmaster T.Flight Stick X</name>
149
+
150
+  <axis n="0">
151
+    <desc>Aileron</desc>
152
+    <binding>
153
+      <command>property-scale</command>
154
+      <property>/controls/flight/aileron</property>
155
+      <squared type="bool">true</squared>
156
+    </binding>
157
+  </axis>
158
+
159
+  <axis n="1">
160
+    <desc>Elevator</desc>
161
+    <binding>
162
+      <command>property-scale</command>
163
+      <property>/controls/flight/elevator</property>
164
+      <factor type="double">-1.0</factor>
165
+      <squared type="bool">true</squared>
166
+    </binding>
167
+  </axis>
168
+
169
+  <axis>
170
+    <number>
171
+      <windows>2</windows>
172
+      <unix>3</unix>
173
+    </number>
174
+    <desc>Increase/Reduce Throttle</desc>
175
+    <binding>
176
+      <command>nasal</command>
177
+      <script>controls.throttleAxis()</script>
178
+    </binding>
179
+  </axis>
180
+
181
+  <axis>
182
+    <number>
183
+      <windows>3</windows>
184
+      <unix>2</unix>
185
+    </number>
186
+    <desc>Rudder Left/Right</desc>
187
+    <binding>
188
+      <command>property-scale</command>
189
+      <property>/controls/flight/rudder</property>
190
+      <factor type="double">1.0</factor>
191
+    </binding>
192
+  </axis>
193
+
194
+  <axis>
195
+    <number>
196
+      <windows>6</windows>
197
+      <unix>4</unix>
198
+    </number>
199
+    <desc>View Direction | reset FoV | reset view direction</desc>
200
+    <low>
201
+      <repeatable>true</repeatable>
202
+      <binding>
203
+        <command>nasal</command>
204
+        <script>chinese_hat(1, 0)</script>
205
+      </binding>
206
+    </low>
207
+    <high>
208
+      <repeatable>true</repeatable>
209
+      <binding>
210
+        <command>nasal</command>
211
+        <script>chinese_hat(-1, 0)</script>
212
+      </binding>
213
+    </high>
214
+  </axis>
215
+
216
+  <axis>
217
+    <number>
218
+      <windows>7</windows>
219
+      <unix>5</unix>
220
+    </number>
221
+    <desc>Orientation up or down / Increase or decrease FoV</desc>
222
+    <low>
223
+      <repeatable>true</repeatable>
224
+      <binding>
225
+        <command>nasal</command>
226
+        <script>chinese_hat(0, 1)</script>
227
+      </binding>
228
+    </low>
229
+    <high>
230
+      <repeatable>true</repeatable>
231
+      <binding>
232
+        <command>nasal</command>
233
+        <script>chinese_hat(0, -1)</script>
234
+      </binding>
235
+    </high>
236
+  </axis>
237
+
238
+  <button n="1">
239
+    <desc>Swap first and second views</desc>
240
+    <binding>
241
+      <command>nasal</command>
242
+      <script>joystick_button[2](1)</script>
243
+    </binding>
244
+    <mod-up>
245
+      <binding>
246
+        <command>nasal</command>
247
+        <script>joystick_button[2](0)</script>
248
+      </binding>
249
+    </mod-up>
250
+  </button>
251
+
252
+  <button n="2">
253
+    <desc>Apply brakes</desc>
254
+    <binding>
255
+      <command>nasal</command>
256
+      <script>joystick_button[3](0)</script>
257
+    </binding>
258
+    <mod-up>
259
+      <binding>
260
+        <command>nasal</command>
261
+        <script>joystick_button[3](1)</script>
262
+      </binding>
263
+    </mod-up>
264
+  </button>
265
+
266
+  <button n="4">
267
+    <desc>Extend Flaps Incrementally</desc>
268
+    <repeatable>false</repeatable>
269
+    <binding>
270
+      <command>nasal</command>
271
+      <script>joystick_button[5]()</script>
272
+    </binding>
273
+  </button>
274
+
275
+  <button n="5">
276
+    <desc>Retract Flaps Incrementally</desc>
277
+    <repeatable>false</repeatable>
278
+    <binding>
279
+      <command>nasal</command>
280
+      <script>joystick_button[6]()</script>
281
+    </binding>
282
+  </button>
283
+
284
+  <button n="6">
285
+    <desc>Handle mixture | add or remove engine 0</desc>
286
+    <repeatable>true</repeatable>
287
+    <binding>
288
+      <command>nasal</command>
289
+      <script>joystick_button[7]()</script>
290
+    </binding>
291
+  </button>
292
+
293
+  <button n="7">
294
+    <desc>Handle mixture | add or remove engine 1</desc>
295
+    <repeatable>true</repeatable>
296
+    <binding>
297
+      <command>nasal</command>
298
+      <script>joystick_button[8]()</script>
299
+    </binding>
300
+  </button>
301
+
302
+  <button n="8">
303
+    <desc>Handle mixture | add or remove engine 2</desc>
304
+    <repeatable>true</repeatable>
305
+    <binding>
306
+      <command>nasal</command>
307
+      <script>joystick_button[9]()</script>
308
+    </binding>
309
+  </button>
310
+
311
+  <button n="9">
312
+    <desc>Handle mixture | add or remove engine 3</desc>
313
+    <repeatable>true</repeatable>
314
+    <binding>
315
+      <command>nasal</command>
316
+      <script>joystick_button[10]()</script>
317
+    </binding>
318
+  </button>
319
+
320
+</PropertyList>
321
+
322
+<!-- end of T.Flight Stick X.xml -->