Debian Codegraph @

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

raw symbols SCIP
1 <?xml version="1.0"?>
2 <!--
3 Copyright (c) 2011 Melchior FRANZ mfranz # aon : at
4
5 This driver supports joystick overlay files (see ./Warthog/README).
6
7 TMS ... Target Management Switch (black, rippled cursor switch, left side)
8 DMS ... Data Management Switch (black cursor switch with flat cross on top, right side)
9 CMS ... Countermeasures Management Switch (grey)
10 -->
11
12 <PropertyList>
13 <name>Thustmaster Joystick - HOTAS Warthog</name>
14 <name>Thrustmaster Joystick - HOTAS Warthog</name> <!-- in case they ever manage to fix their name -->
15 <name>Joystick - HOTAS Warthog</name>
16
17 <nasal>
18 <script>
19 var this = cmdarg().getParent();
20 var init = !contains(caller(0)[0], "init");
21 if (!contains(globals, "warthog"))
22 io.load_nasal(getprop("/sim/fg-root") ~ "/Input/Joysticks/ThrustMaster/Warthog/warthog.nas");
23
24 var jslistener = func init and call(setlistener, arg);
25 var popup = func gui.popupTip(call(sprintf, arg));
26 var is_helicopter = (func {(var n = props.globals.getNode("rotors", 0)) != nil and n.getAttribute("children")})();
27 var aircraft_type = getprop("/sim/type");
28
29 var load_overlay = func(name) {
30 foreach (var dir; [getprop("/sim/fg-home"), getprop("/sim/fg-root")]) {
31 var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Stick/" ~ name ~ ".xml";
32 if (io.stat(file) != nil) {
33 printlog("info", "WARTHOG: loading overlay " ~ file);
34 cmdarg().setValues({command: "nasal", script: ""});
35 io.read_properties(file, this);
36 props.runBinding(cmdarg());
37 break;
38 }
39 }
40 }
41
42 foreach (var b; this.getChildren("button")) {
43 if (b.getAttribute("children") == 1) {
44 var name = b.getNode("name", 1).getValue() or "??";
45 b.setValues({binding: {command: "nasal", script: 'popup("' ~ name ~ '")'}});
46 }
47 }
48
49 var mod = 0;
50 var m = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT");
51 jslistener(m, func(n) mod = n.getValue());
52
53 var trimstep = 0.75;
54 var viewstep = 1.5;
55 var button = {18: {id: 0}};
56
57 var reset_zoom = func setprop("/sim/current-view/field-of-view", 55);
58 var viewdir = props.globals.getNode("/sim").getChildren("view");
59 forindex (var i; viewdir) {
60 var t = viewdir[i].getNode("type");
61 viewdir[i] = t != nil and t.getValue() == "lookat" ? 1 : -1;
62 }
63
64 load_overlay("generic");
65 if (is_helicopter)
66 load_overlay("helicopter");
67 if (aircraft_type)
68 load_overlay(aircraft_type);
69 foreach (var o; split(":", getprop("/input/joysticks/overlays") or ""))
70 load_overlay(o);
71 load_overlay(getprop("/sim/aircraft"));
72 </script>
73 </nasal>
74
75 <axis n="0">
76 <name>X-axis</name>
77 <desc>aileron</desc>
78 <tolerance>0.00001</tolerance>
79 <binding>
80 <command>property-scale</command>
81 <property>/controls/flight/aileron</property>
82 </binding>
83 </axis>
84
85 <axis n="1">
86 <name>Y-axis</name>
87 <desc>elevator</desc>
88 <tolerance>0.00001</tolerance>
89 <binding>
90 <command>property-scale</command>
91 <property>/controls/flight/elevator</property>
92 <factor type="double">-1.0</factor>
93 </binding>
94 </axis>
95
96 <axis>
97 <name>Trim Hat Switch Left/Right</name>
98 <desc>adjust aileron trim, +mod: reset aileron trim</desc>
99 <number>
100 <unix>2</unix>
101 </number>
102 <low>
103 <repeatable>true</repeatable>
104 <binding>
105 <command>nasal</command>
106 <script>
107 if (mod)
108 setprop("/controls/flight/aileron-trim", 0);
109 else
110 controls.aileronTrim(-trimstep);
111 </script>
112 </binding>
113 </low>
114 <high>
115 <repeatable>true</repeatable>
116 <binding>
117 <command>nasal</command>
118 <script>
119 if (mod)
120 setprop("/controls/flight/aileron-trim", 0);
121 else
122 controls.aileronTrim(trimstep);
123 </script>
124 </binding>
125 </high>
126 </axis>
127
128 <!--Please fix me: axis are duplicated due to different binding per OS-->
129
130 <axis>
131 <name>Trim Hat Switch Left/Right</name>
132 <desc>adjust aileron trim, +mod: reset aileron trim</desc>
133 <number>
134 <windows>6</windows>
135 </number>
136 <low>
137 <repeatable>true</repeatable>
138 <binding>
139 <command>nasal</command>
140 <script>
141 if (mod)
142 setprop("/controls/flight/aileron-trim", 0);
143 else
144 controls.aileronTrim(-trimstep);
145 </script>
146 </binding>
147 </low>
148 <high>
149 <repeatable>true</repeatable>
150 <binding>
151 <command>nasal</command>
152 <script>
153 if (mod)
154 setprop("/controls/flight/aileron-trim", 0);
155 else
156 controls.aileronTrim(trimstep);
157 </script>
158 </binding>
159 </high>
160 </axis>
161
162 <axis>
163 <name>Trim Hat Switch Down/Up</name>
164 <desc>adjust elevator trim, +mod: reset elevator trim</desc>
165 <number>
166 <unix>3</unix>
167 </number>
168 <low>
169 <repeatable>true</repeatable>
170 <binding>
171 <command>nasal</command>
172 <script>
173 if (mod)
174 setprop("/controls/flight/elevator-trim", 0);
175 else
176 controls.elevatorTrim(trimstep);
177 </script>
178 </binding>
179 </low>
180 <high>
181 <repeatable>true</repeatable>
182 <binding>
183 <command>nasal</command>
184 <script>
185 if (mod)
186 setprop("/controls/flight/elevator-trim", 0);
187 else
188 controls.elevatorTrim(-trimstep);
189 </script>
190 </binding>
191 </high>
192 </axis>
193
194 <!--Please fix me: axis are duplicated due to different binding per OS-->
195
196 <axis>
197 <name>Trim Hat Switch Down/Up</name>
198 <desc>adjust elevator trim, +mod: reset elevator trim</desc>
199 <number>
200 <windows>7</windows>
201 </number>
202 <low>
203 <repeatable>true</repeatable>
204 <binding>
205 <command>nasal</command>
206 <script>
207 if (mod)
208 setprop("/controls/flight/elevator-trim", 0);
209 else
210 controls.elevatorTrim(-trimstep);
211 </script>
212 </binding>
213 </low>
214 <high>
215 <repeatable>true</repeatable>
216 <binding>
217 <command>nasal</command>
218 <script>
219 if (mod)
220 setprop("/controls/flight/elevator-trim", 0);
221 else
222 controls.elevatorTrim(trimstep);
223 </script>
224 </binding>
225 </high>
226 </axis>
227
228 <button n="0">
229 <name>Trigger Button/Half Pushed</name>
230 <desc>camera oper</desc>
231 </button>
232
233 <button n="1">
234 <name>Weapons Release</name>
235 </button>
236
237 <button n="2">
238 <name>Nosewheel Steering Button</name>
239 <desc>toggle nosewheel steering/tailwheel lock</desc>
240 <binding>
241 <command>nasal</command>
242 <script>
243 var i = !(getprop("/controls/gear/nose-wheel-steering") or 0);
244 setprop("/controls/gear/nose-wheel-steering", i);
245 setprop("/controls/gear/tailwheel-lock", !i);
246 popup("Tail Wheel %sLOCKED!", i ? "UN" : "");
247 </script>
248 </binding>
249 </button>
250
251 <button n="3">
252 <name>Paddle Switch</name>
253 <desc>modifier button</desc>
254 <binding>
255 <command>property-assign</command>
256 <property>/devices/status/joysticks/warthog/modifier</property>
257 <value>1</value>
258 </binding>
259 <mod-up>
260 <binding>
261 <command>property-assign</command>
262 <property>/devices/status/joysticks/warthog/modifier</property>
263 <value>0</value>
264 </binding>
265 </mod-up>
266 </button>
267
268 <button n="4">
269 <name>Master Mode Control Button</name>
270 </button>
271
272 <button n="5">
273 <name>Trigger Button/Fully Pushed</name>
274 <desc>gun trigger</desc>
275 <binding>
276 <command>nasal</command>
277 <script>controls.trigger(1)</script>
278 </binding>
279 <mod-up>
280 <binding>
281 <command>nasal</command>
282 <script>controls.trigger(0)</script>
283 </binding>
284 </mod-up>
285 </button>
286
287 <button n="6">
288 <name>left black curosr (TMS) up</name>
289 <desc>brakes, +mod: toggle parking brake</desc>
290 <binding>
291 <command>nasal</command>
292 <script>controls.applyBrakes(1)</script>
293 </binding>
294 <mod-up>
295 <binding>
296 <command>nasal</command>
297 <script>
298 if (mod) {
299 var i = controls.applyParkingBrake(1);
300 popup("Parking Brake %s", i ? "ON" : "OFF");
301 }
302 controls.applyBrakes(0)
303 </script>
304 </binding>
305 </mod-up>
306 </button>
307
308 <button n="7">
309 <name>left black cursor (TMS) right</name>
310 <desc>brakes right</desc>
311 <binding>
312 <command>nasal</command>
313 <script>controls.applyBrakes(1, 1)</script>
314 </binding>
315 <mod-up>
316 <binding>
317 <command>nasal</command>
318 <script>controls.applyBrakes(0, 1)</script>
319 </binding>
320 </mod-up>
321 </button>
322
323 <button n="8">
324 <name>left black cursor (TMS) down</name>
325 <desc>brakes, +mod: toggle parking brake</desc>
326 <binding>
327 <command>nasal</command>
328 <script>controls.applyBrakes(1)</script>
329 </binding>
330 <mod-up>
331 <binding>
332 <command>nasal</command>
333 <script>
334 if (mod) {
335 var i = controls.applyParkingBrake(1);
336 popup("Parking Brake %s", i ? "ON" : "OFF");
337 }
338 controls.applyBrakes(0)
339 </script>
340 </binding>
341 </mod-up>
342 </button>
343
344 <button n="9">
345 <name>left black cursor (TMS) left</name>
346 <desc>brakes left</desc>
347 <binding>
348 <command>nasal</command>
349 <script>controls.applyBrakes(1, -1)</script>
350 </binding>
351 <mod-up>
352 <binding>
353 <command>nasal</command>
354 <script>controls.applyBrakes(0, -1)</script>
355 </binding>
356 </mod-up>
357 </button>
358
359 <button n="10">
360 <name>right black cursor (DMS) up</name>
361 <desc>zoom in, +mod: reset zoom</desc>
362 <repeatable>true</repeatable>
363 <binding>
364 <command>nasal</command>
365 <script>
366 if (mod)
367 reset_zoom();
368 else
369 view.decrease(1);
370 </script>
371 </binding>
372 </button>
373
374 <button n="11">
375 <name>right black cursor (DMS) right</name>
376 <desc>next active view, +mod: next view</desc>
377 <binding>
378 <command>nasal</command>
379 <script>view.stepView(1, mod)</script>
380 </binding>
381 </button>
382
383 <button n="12">
384 <name>right black cursor (DMS) down</name>
385 <desc>zoom out, +mod: reset zoom</desc>
386 <repeatable>true</repeatable>
387 <binding>
388 <command>nasal</command>
389 <script>
390 if (mod)
391 reset_zoom();
392 else
393 view.increase(1);
394 </script>
395 </binding>
396 </button>
397
398 <button n="13">
399 <name>right black cursor (DMS) left</name>
400 <desc>previous active view, +mod: previous view</desc>
401 <binding>
402 <command>nasal</command>
403 <script>view.stepView(-1, mod)</script>
404 </binding>
405 </button>
406
407 <button n="14">
408 <name>grey cursor (CMS) up</name>
409 <desc>view up</desc>
410 <repeatable>true</repeatable>
411 <binding>
412 <command>nasal</command>
413 <script>view.panViewPitch(viewstep)</script>
414 </binding>
415 </button>
416
417 <button n="15">
418 <name>grey cursor (CMS) right</name>
419 <desc>view right</desc>
420 <repeatable>true</repeatable>
421 <binding>
422 <command>nasal</command>
423 <script>view.panViewDir(viewdir[view.index] * viewstep)</script>
424 </binding>
425 </button>
426
427 <button n="16">
428 <name>grey cursor (CMS) down</name>
429 <desc>view down</desc>
430 <repeatable>true</repeatable>
431 <binding>
432 <command>nasal</command>
433 <script>view.panViewPitch(-viewstep)</script>
434 </binding>
435 </button>
436
437 <button n="17">
438 <name>grey cursor (CMS) left</name>
439 <desc>view left</desc>
440 <repeatable>true</repeatable>
441 <binding>
442 <command>nasal</command>
443 <script>view.panViewDir(-viewdir[view.index] * viewstep)</script>
444 </binding>
445 </button>
446
447 <button n="18">
448 <name>grey cursor (CMS) push</name>
449 <desc>short: center view, long (&gt;0.5 sec): centered cockpit view</desc>
450 <binding>
451 <command>nasal</command>
452 <script>
453 (func(id) {
454 settimer(func {
455 if (id == button[18].id) {
456 setprop("/sim/current-view/view-number", 0);
457 view.resetView();
458 }
459 }, 0.5, 1);
460 })(button[18].id += 1);
461 </script>
462 </binding>
463 <mod-up>
464 <binding>
465 <command>nasal</command>
466 <script>
467 button[18].id += 1;
468 view.resetView();
469 </script>
470 </binding>
471 </mod-up>
472 </button>
473 </PropertyList>