... | ... |
@@ -0,0 +1,429 @@ |
1 |
+<?xml version="1.0"?> |
|
2 |
+ |
|
3 |
+<!-- |
|
4 |
+Buttons 1, 11 and 12 are modifiers |
|
5 |
+ |
|
6 |
+Modifier | | button 1 | button 11 | button 12 |
|
7 |
+============================================================================================= |
|
8 |
+Hat up | look up | zoom in | trim elevator up | |
|
9 |
+Hat down | look down | zoom out | trim elevator down | |
|
10 |
+Hat left | look left | reset FoV + heading | trim rudder left | trim aileron left |
|
11 |
+Hat right | look right | reset FoV | trim rudder right | trim aileron right |
|
12 |
+ |
|
13 |
+Button 2 | heli view | permanent heli view | show/hide pins | declutter pins |
|
14 |
+Button 3 | brakes | | | |
|
15 |
+Button 4 | PTT COMM 1 | PTT COMM 2 | | |
|
16 |
+Button 5 | flaps down | inHg += 0.01 | | |
|
17 |
+Button 6 | flaps up | inHg -= 0.01 | control all engines | uncontrol all engines |
|
18 |
+Button 7 | inc mixture | inc mixture (x10) | control engine 2 | uncontrol engine 2 |
|
19 |
+Button 8 | dec mixture | dec mixture (x10) | control engine 3 | uncontrol engine 3 |
|
20 |
+Button 9 | inc proppitch | inc proppitch (x10) | control engine 1 | uncontrol engine 1 |
|
21 |
+Button 10 | dec proppitch | dec proppitch (x10) | control engine 0 | uncontrol engine 0 |
|
22 |
+ |
|
23 |
+Mouse mode: |
|
24 |
+the mouse mode to control aicraft will be disabled, and restored at the end of the session. |
|
25 |
+Pressing button 2 will also set the mouse mode to control the view direction, and restore its previous |
|
26 |
+state when back to normal view |
|
27 |
+--> |
|
28 |
+ |
|
29 |
+<PropertyList> |
|
30 |
+ <nasal> |
|
31 |
+ <script><![CDATA[ |
|
32 |
+ var skipFlightControls = props.globals.getNode("/sim/mouse/skip-flight-controls-mode"); |
|
33 |
+ setlistener("/sim/signals/fdm-initilized", func { |
|
34 |
+ skipFlightControls.setBoolValue(1); |
|
35 |
+ print("JOYSTICK set mouse flight control OFF: ", skipFlightControls.getValue()); |
|
36 |
+ }, 1 ); |
|
37 |
+ setlistener("/sim/signals/save", func { |
|
38 |
+ skipFlightControls.setBoolValue(0); |
|
39 |
+ print("JOYSTICK save mouse flight control ON: ", skipFlightControls.getValue()); |
|
40 |
+ } ); |
|
41 |
+ |
|
42 |
+ # determine Nasal namespace for this joystick |
|
43 |
+ # stored in js[0] |
|
44 |
+ string.scanf(cmdarg().getNode("module").getValue(), "__js%u", var js = []); |
|
45 |
+ |
|
46 |
+ # array with prop path for each button status |
|
47 |
+ var pressed_button = []; |
|
48 |
+ for (var i = 0; i < 12; i += 1) |
|
49 |
+ append(pressed_button, "/devices/status/joysticks/joystick[" ~ js[0] ~ "]/button[" ~ i ~ "]"); |
|
50 |
+ |
|
51 |
+ var previousMouseMode = 0; |
|
52 |
+ var locked_view = 0; |
|
53 |
+ |
|
54 |
+ var chinese_hat = func (heading, pitch) { |
|
55 |
+ if (getprop(pressed_button[0])) { |
|
56 |
+ if (pitch > 0) view.decrease(); |
|
57 |
+ elsif (pitch < 0) view.increase(); |
|
58 |
+ elsif (heading > 0){view.resetViewDir();view.resetFOV();} |
|
59 |
+ elsif (heading < 0) view.resetFOV(); |
|
60 |
+ } |
|
61 |
+ elsif (getprop(pressed_button[10])) { |
|
62 |
+ if (pitch) |
|
63 |
+ controls.elevatorTrim(pitch); |
|
64 |
+ else |
|
65 |
+ controls.rudderTrim(heading); |
|
66 |
+ } |
|
67 |
+ elsif (getprop(pressed_button[11]) and heading) { |
|
68 |
+ controls.aileronTrim(-heading); |
|
69 |
+ } |
|
70 |
+ else { |
|
71 |
+ if (heading) { |
|
72 |
+ fgcommand("property-adjust", { |
|
73 |
+ property : "/sim/current-view/goal-heading-offset-deg", |
|
74 |
+ step : 2.0 * heading |
|
75 |
+ }); |
|
76 |
+ } |
|
77 |
+ elsif (pitch) { |
|
78 |
+ fgcommand("property-adjust", { |
|
79 |
+ property : "/sim/current-view/goal-pitch-offset-deg", |
|
80 |
+ step : 2.0 * pitch |
|
81 |
+ }); |
|
82 |
+ } |
|
83 |
+ } |
|
84 |
+ } |
|
85 |
+ |
|
86 |
+ var addSelectedEngine = func (i) { |
|
87 |
+ controls.engines[i].selected.setBoolValue(1); |
|
88 |
+ printf("engine %d added to joystick controls", i); |
|
89 |
+ gui.popupTip("engine " ~ i ~ " joystick controlled"); |
|
90 |
+ } |
|
91 |
+ |
|
92 |
+ var removeSelectedEngine = func (i) { |
|
93 |
+ controls.engines[i].selected.setBoolValue(0); |
|
94 |
+ printf("engine %d removed from joystick controls", i); |
|
95 |
+ gui.popupTip("engine " ~ i ~ " joystick uncontrolled"); |
|
96 |
+ } |
|
97 |
+ |
|
98 |
+ # key = button identifier as displayed on joystick |
|
99 |
+ joystick_button = { |
|
100 |
+ 2 : func (pressed) { |
|
101 |
+ if (pressed) { |
|
102 |
+ if (getprop(pressed_button[10])) { |
|
103 |
+ setprop("/sim/marker-pins/master", !getprop("/sim/marker-pins/master")); |
|
104 |
+ } |
|
105 |
+ elsif (getprop(pressed_button[11])) { |
|
106 |
+ var clutter = { |
|
107 |
+ "airports": 1, |
|
108 |
+ "pois" : 2, |
|
109 |
+ "traffic" : 4, |
|
110 |
+ "navaids" : 8, |
|
111 |
+ "fixes" : 16 |
|
112 |
+ }; |
|
113 |
+ var clutter_sum = 0; |
|
114 |
+ foreach (var c; keys(clutter)) { |
|
115 |
+ clutter_sum += getprop("/sim/marker-pins/" ~ c) * clutter[c] |
|
116 |
+ } |
|
117 |
+ if (clutter_sum == 1) { |
|
118 |
+ setprop("/sim/marker-pins/fixes", 0); |
|
119 |
+ setprop("/sim/marker-pins/navaids", 0); |
|
120 |
+ setprop("/sim/marker-pins/airports", 1); |
|
121 |
+ setprop("/sim/marker-pins/pois", 1); |
|
122 |
+ setprop("/sim/marker-pins/traffic", 0); |
|
123 |
+ gui.popupTip("Pins: AIRPORTS + POI", 1); |
|
124 |
+ } |
|
125 |
+ elsif (clutter_sum == 3) { |
|
126 |
+ setprop("/sim/marker-pins/fixes", 0); |
|
127 |
+ setprop("/sim/marker-pins/navaids", 0); |
|
128 |
+ setprop("/sim/marker-pins/airports", 0); |
|
129 |
+ setprop("/sim/marker-pins/pois", 0); |
|
130 |
+ setprop("/sim/marker-pins/traffic", 1); |
|
131 |
+ gui.popupTip("Pins: TRAFFIC", 1); |
|
132 |
+ } |
|
133 |
+ elsif (clutter_sum == 4) { |
|
134 |
+ setprop("/sim/marker-pins/fixes", 1); |
|
135 |
+ setprop("/sim/marker-pins/navaids", 1); |
|
136 |
+ setprop("/sim/marker-pins/airports", 1); |
|
137 |
+ setprop("/sim/marker-pins/pois", 0); |
|
138 |
+ setprop("/sim/marker-pins/traffic", 0); |
|
139 |
+ gui.popupTip("Pins: AIRPORTS + NAVAIDS + FIXES", 1); |
|
140 |
+ } |
|
141 |
+ else { |
|
142 |
+ setprop("/sim/marker-pins/fixes", 0); |
|
143 |
+ setprop("/sim/marker-pins/navaids", 0); |
|
144 |
+ setprop("/sim/marker-pins/airports", 1); |
|
145 |
+ setprop("/sim/marker-pins/pois", 0); |
|
146 |
+ setprop("/sim/marker-pins/traffic", 0); |
|
147 |
+ gui.popupTip("Pins: AIRPORTS", 1); |
|
148 |
+ } |
|
149 |
+ setprop("/sim/marker-pins/master", 1); |
|
150 |
+ } |
|
151 |
+ else { |
|
152 |
+ locked_view = getprop(pressed_button[0]); |
|
153 |
+ setprop("/devices/status/mice/mouse[0]/mode", 2); |
|
154 |
+ setprop("/sim/current-view/view-number", 1); |
|
155 |
+ } |
|
156 |
+ } |
|
157 |
+ else { |
|
158 |
+ if (locked_view) |
|
159 |
+ return; |
|
160 |
+ setprop("/devices/status/mice/mouse[0]/mode", 0); |
|
161 |
+ setprop("/sim/current-view/view-number", 0); |
|
162 |
+ } |
|
163 |
+ }, |
|
164 |
+ |
|
165 |
+ 3 : func (pressed) { |
|
166 |
+ controls.applyBrakes(pressed) |
|
167 |
+ }, |
|
168 |
+ |
|
169 |
+ 4 : func (pressed) { |
|
170 |
+ if (pressed) { |
|
171 |
+ var comm = getprop(pressed_button[0]) + 1; |
|
172 |
+ controls.ptt(comm); |
|
173 |
+ gui.popupTip("PTT COMM " ~ comm); |
|
174 |
+ } |
|
175 |
+ else { |
|
176 |
+ controls.ptt(0); |
|
177 |
+ gui.popupTip("PTT COMM ends", 0.5); |
|
178 |
+ } |
|
179 |
+ |
|
180 |
+ }, |
|
181 |
+ |
|
182 |
+ 5 : func { |
|
183 |
+ if (getprop(pressed_button[0])) |
|
184 |
+ fgcommand("property-adjust", { |
|
185 |
+ property: "/instrumentation/altimeter/setting-inhg", |
|
186 |
+ step: 0.01 |
|
187 |
+ }); |
|
188 |
+ else |
|
189 |
+ controls.flapsDown(1) |
|
190 |
+ }, |
|
191 |
+ |
|
192 |
+ 6 : func { |
|
193 |
+ if (getprop(pressed_button[0])) |
|
194 |
+ fgcommand("property-adjust", { |
|
195 |
+ property: "/instrumentation/altimeter/setting-inhg", |
|
196 |
+ step: -0.01 |
|
197 |
+ }); |
|
198 |
+ elsif (getprop(pressed_button[10])) { |
|
199 |
+ for (var i = 0; i < 4; i += 1) |
|
200 |
+ controls.engines[i].selected.setBoolValue(1); |
|
201 |
+ printf("all engines added to joystick controls"); |
|
202 |
+ gui.popupTip("joystick controls all engines"); |
|
203 |
+ } |
|
204 |
+ elsif (getprop(pressed_button[11])) { |
|
205 |
+ for (var i = 0; i < 4; i += 1) |
|
206 |
+ controls.engines[i].selected.setBoolValue(0); |
|
207 |
+ printf("joystick controls no engines", i); |
|
208 |
+ gui.popupTip("joystick controls no engine"); |
|
209 |
+ } |
|
210 |
+ else |
|
211 |
+ controls.flapsDown(-1) |
|
212 |
+ }, |
|
213 |
+ |
|
214 |
+ 7 : func { |
|
215 |
+ if (getprop(pressed_button[10])) addSelectedEngine(2); |
|
216 |
+ elsif (getprop(pressed_button[11])) removeSelectedEngine(2); |
|
217 |
+ else controls.adjMixture(-0.1 - 0.9 * getprop(pressed_button[0])); |
|
218 |
+ }, |
|
219 |
+ |
|
220 |
+ 8 : func { |
|
221 |
+ if (getprop(pressed_button[10])) addSelectedEngine(3); |
|
222 |
+ elsif (getprop(pressed_button[11])) removeSelectedEngine(3); |
|
223 |
+ else controls.adjMixture(0.1 + 0.9 * getprop(pressed_button[0])); |
|
224 |
+ }, |
|
225 |
+ |
|
226 |
+ 9 : func { |
|
227 |
+ if (getprop(pressed_button[10])) addSelectedEngine(1); |
|
228 |
+ elsif (getprop(pressed_button[11])) removeSelectedEngine(1); |
|
229 |
+ else controls.adjPropeller(0.1 + 0.9 * getprop(pressed_button[0])); |
|
230 |
+ }, |
|
231 |
+ |
|
232 |
+ 10 : func { |
|
233 |
+ if (getprop(pressed_button[10])) addSelectedEngine(0); |
|
234 |
+ elsif (getprop(pressed_button[11])) removeSelectedEngine(0); |
|
235 |
+ else controls.adjPropeller(-0.1 - 0.9 * getprop(pressed_button[0])); |
|
236 |
+ }, |
|
237 |
+ } |
|
238 |
+ ]]></script> |
|
239 |
+ </nasal> |
|
240 |
+ |
|
241 |
+ <name type="string">DragonRise Inc. Generic USB Joystick </name> |
|
242 |
+ |
|
243 |
+ <axis n="0"> |
|
244 |
+ <desc>Aileron</desc> |
|
245 |
+ <binding> |
|
246 |
+ <command>property-scale</command> |
|
247 |
+ <property>/controls/flight/aileron</property> |
|
248 |
+ <squared type="bool">true</squared> |
|
249 |
+ </binding> |
|
250 |
+ </axis> |
|
251 |
+ |
|
252 |
+ <axis n="1"> |
|
253 |
+ <desc>Elevator</desc> |
|
254 |
+ <binding> |
|
255 |
+ <command>property-scale</command> |
|
256 |
+ <property>/controls/flight/elevator</property> |
|
257 |
+ <factor type="double">-1.0</factor> |
|
258 |
+ <squared type="bool">true</squared> |
|
259 |
+ </binding> |
|
260 |
+ </axis> |
|
261 |
+ |
|
262 |
+ <axis> |
|
263 |
+ <number> |
|
264 |
+ <windows>2</windows> |
|
265 |
+ <unix>3</unix> |
|
266 |
+ </number> |
|
267 |
+ <desc>Increase/Reduce Throttle</desc> |
|
268 |
+ <binding> |
|
269 |
+ <command>nasal</command> |
|
270 |
+ <script>controls.throttleAxis()</script> |
|
271 |
+ </binding> |
|
272 |
+ </axis> |
|
273 |
+ |
|
274 |
+ <axis> |
|
275 |
+ <number> |
|
276 |
+ <windows>3</windows> |
|
277 |
+ <unix>2</unix> |
|
278 |
+ </number> |
|
279 |
+ <desc>Rudder Left/Right</desc> |
|
280 |
+ <binding> |
|
281 |
+ <command>property-scale</command> |
|
282 |
+ <property>/controls/flight/rudder</property> |
|
283 |
+ <factor type="double">1.0</factor> |
|
284 |
+ </binding> |
|
285 |
+ </axis> |
|
286 |
+ |
|
287 |
+ <axis> |
|
288 |
+ <number> |
|
289 |
+ <windows>6</windows> |
|
290 |
+ <unix>4</unix> |
|
291 |
+ </number> |
|
292 |
+ <desc>View Direction | reset FoV | reset view direction</desc> |
|
293 |
+ <low> |
|
294 |
+ <repeatable>true</repeatable> |
|
295 |
+ <binding> |
|
296 |
+ <command>nasal</command> |
|
297 |
+ <script>chinese_hat(1, 0)</script> |
|
298 |
+ </binding> |
|
299 |
+ </low> |
|
300 |
+ <high> |
|
301 |
+ <repeatable>true</repeatable> |
|
302 |
+ <binding> |
|
303 |
+ <command>nasal</command> |
|
304 |
+ <script>chinese_hat(-1, 0)</script> |
|
305 |
+ </binding> |
|
306 |
+ </high> |
|
307 |
+ </axis> |
|
308 |
+ |
|
309 |
+ <axis> |
|
310 |
+ <number> |
|
311 |
+ <windows>7</windows> |
|
312 |
+ <unix>5</unix> |
|
313 |
+ </number> |
|
314 |
+ <desc>Orientation up or down / Increase or decrease FoV</desc> |
|
315 |
+ <low> |
|
316 |
+ <repeatable>true</repeatable> |
|
317 |
+ <binding> |
|
318 |
+ <command>nasal</command> |
|
319 |
+ <script>chinese_hat(0, 1)</script> |
|
320 |
+ </binding> |
|
321 |
+ </low> |
|
322 |
+ <high> |
|
323 |
+ <repeatable>true</repeatable> |
|
324 |
+ <binding> |
|
325 |
+ <command>nasal</command> |
|
326 |
+ <script>chinese_hat(0, -1)</script> |
|
327 |
+ </binding> |
|
328 |
+ </high> |
|
329 |
+ </axis> |
|
330 |
+ |
|
331 |
+ <button n="1"> |
|
332 |
+ <desc>Swap first and second views | pins POIs</desc> |
|
333 |
+ <binding> |
|
334 |
+ <command>nasal</command> |
|
335 |
+ <script>joystick_button[2](1)</script> |
|
336 |
+ </binding> |
|
337 |
+ <mod-up> |
|
338 |
+ <binding> |
|
339 |
+ <command>nasal</command> |
|
340 |
+ <script>joystick_button[2](0)</script> |
|
341 |
+ </binding> |
|
342 |
+ </mod-up> |
|
343 |
+ </button> |
|
344 |
+ |
|
345 |
+ <button n="2"> |
|
346 |
+ <desc>Apply brakes</desc> |
|
347 |
+ <binding> |
|
348 |
+ <command>nasal</command> |
|
349 |
+ <script>joystick_button[3](1)</script> |
|
350 |
+ </binding> |
|
351 |
+ <mod-up> |
|
352 |
+ <binding> |
|
353 |
+ <command>nasal</command> |
|
354 |
+ <script>joystick_button[3](0)</script> |
|
355 |
+ </binding> |
|
356 |
+ </mod-up> |
|
357 |
+ </button> |
|
358 |
+ |
|
359 |
+ <button n="3"> |
|
360 |
+ <desc>PTT - Push To Talk (via FGCom)</desc> |
|
361 |
+ <binding> |
|
362 |
+ <command>nasal</command> |
|
363 |
+ <script>joystick_button[4](1)</script> |
|
364 |
+ </binding> |
|
365 |
+ <mod-up> |
|
366 |
+ <binding> |
|
367 |
+ <command>nasal</command> |
|
368 |
+ <script>joystick_button[4](0)</script> |
|
369 |
+ </binding> |
|
370 |
+ </mod-up> |
|
371 |
+ </button> |
|
372 |
+ |
|
373 |
+ <button n="4"> |
|
374 |
+ <desc>Extend Flaps Incrementally</desc> |
|
375 |
+ <repeatable>false</repeatable> |
|
376 |
+ <binding> |
|
377 |
+ <command>nasal</command> |
|
378 |
+ <script>joystick_button[5]()</script> |
|
379 |
+ </binding> |
|
380 |
+ </button> |
|
381 |
+ |
|
382 |
+ <button n="5"> |
|
383 |
+ <desc>Retract Flaps Incrementally</desc> |
|
384 |
+ <repeatable>false</repeatable> |
|
385 |
+ <binding> |
|
386 |
+ <command>nasal</command> |
|
387 |
+ <script>joystick_button[6]()</script> |
|
388 |
+ </binding> |
|
389 |
+ </button> |
|
390 |
+ |
|
391 |
+ <button n="6"> |
|
392 |
+ <desc>Handle mixture | add or remove engine 0</desc> |
|
393 |
+ <repeatable>true</repeatable> |
|
394 |
+ <binding> |
|
395 |
+ <command>nasal</command> |
|
396 |
+ <script>joystick_button[7]()</script> |
|
397 |
+ </binding> |
|
398 |
+ </button> |
|
399 |
+ |
|
400 |
+ <button n="7"> |
|
401 |
+ <desc>Handle mixture | add or remove engine 1</desc> |
|
402 |
+ <repeatable>true</repeatable> |
|
403 |
+ <binding> |
|
404 |
+ <command>nasal</command> |
|
405 |
+ <script>joystick_button[8]()</script> |
|
406 |
+ </binding> |
|
407 |
+ </button> |
|
408 |
+ |
|
409 |
+ <button n="8"> |
|
410 |
+ <desc>Handle prop-pitch | add or remove engine 2</desc> |
|
411 |
+ <repeatable>true</repeatable> |
|
412 |
+ <binding> |
|
413 |
+ <command>nasal</command> |
|
414 |
+ <script>joystick_button[9]()</script> |
|
415 |
+ </binding> |
|
416 |
+ </button> |
|
417 |
+ |
|
418 |
+ <button n="9"> |
|
419 |
+ <desc>Handle prop-pitch | add or remove engine 3</desc> |
|
420 |
+ <repeatable>true</repeatable> |
|
421 |
+ <binding> |
|
422 |
+ <command>nasal</command> |
|
423 |
+ <script>joystick_button[10]()</script> |
|
424 |
+ </binding> |
|
425 |
+ </button> |
|
426 |
+ |
|
427 |
+</PropertyList> |
|
428 |
+ |
|
429 |
+<!-- end of T.Flight Stick X.xml --> |