Debian Codegraph @

Input/Joysticks/Default/joypad.xml

raw symbols SCIP
1 <?xml version="1.0"?>
2
3 <!--
4 generic.xml - FlightGear driver for the DragonRise Inc. Generic USB Joystick
5 Copyright (C) 2013 Florent Rougon
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
21 ******************************************************************************
22 * Axes and Buttons Layout *
23 ******************************************************************************
24
25 In the following ASCII-art representation of the joypad:
26 - a single digit represents a button (and gives the button number);
27 - a digit followed by a + or - sign represents an axis direction (and gives
28 the axis number).
29
30 The Top View below shows 4 real axes (0 and 1 on the left stick, 3 and 4 on
31 the right stick) and 2 pseudo-axes (5 and 6). Pseudo-axes are simple buttons
32 in the hardware. Contrary to a real axis, each pseudo-axis only allows 3
33 values: -1, 0, 1.
34
35 Don't forget to put the joypad in analog mode! This changes the center point of
36 axes, for one.
37
38
39 Top View
40 ~~~~~~~~~
41
42 6- 0
43 5- 5+ 8 (SELECT) (START) 9 3 1
44 6+ ANALOG 2
45
46 1- 4-
47 0- 0+ 3- 3+
48 1+ 4+
49
50 (buttons and axes numbers obtained on Linux)
51
52
53 Bottom View
54 ~~~~~~~~~~~
55
56 5 4
57
58 7 6
59
60 (buttons numbers obtained on Linux)
61
62
63 ******************************************************************************
64 * Buttons and Axes Bindings *
65 ******************************************************************************
66
67 Modifiers
68 ~~~~~~~~~
69
70 The two pseudo-axes (5 and 6) are used to define three variables (mod1, mod2,
71 mod3) that act as modifiers for other buttons and axes.
72
73 Initially, mod1 == mod2 == mod3 == 0.
74
75 Pressing button 6- toggles mod1 between the values 0 and 1.
76 Pressing button 6+ toggles mod2 between the values 0 and 1 (mod2 is
77 currently unused).
78
79 When neither 5- nor 5+ is pressed: mod3 == 0
80 As long as 5- is pressed and 5+ is released: mod3 == -1
81 As long as 5+ is pressed and 5- is released: mod3 == 1
82
83 (the result of holding both 5- and 5+ at the same time is undefined)
84
85 Bindings that don't depend on modifier states
86 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87
88 Axis 0 Aileron
89 Axis 1 Elevator
90 Axis 3 Rudder
91 Button 4 View Cycle (backward)
92 Button 5 View Cycle (forward)
93 Button 6 View Decrease
94 Button 7 View Increase
95
96 When mod3 == 0
97 ~~~~~~~~~~~~~~
98
99 [if mod1 == 0]
100 Axis 4 Throttle
101 Button 0 View Up
102 Button 1 View Right
103 Button 2 View Down
104 Button 3 View Left
105 Button 8 Apply Brakes
106 Button 9 Select Initial View and Recenter
107
108 [if mod1 == 1]
109 Button 3 Trigger (weapon)
110 Button 1 Trigger1 (other weapon)
111
112 When mod3 == -1
113 ~~~~~~~~~~~~~~~
114
115 Axis 4 Elevator Trim
116 Button 0 Flaps Up
117 Button 2 Flaps Down
118 Button 3 Brake Left
119 Button 1 Brake Right
120 Button 8 Aileron and Rudder Dance (for kids!)
121 Button 9 Reset Zoom to Default
122
123 When mod3 == 1
124 ~~~~~~~~~~~~~~
125
126 Axis 4 Mixture Control
127 Button 0 Select First Engine
128 Button 1 Select Second Engine
129 Button 2 Select Third Engine
130 Button 3 Select Fourth Engine
131 Button 9 Select All Engines
132
133 -->
134
135 <PropertyList>
136
137 <name>DragonRise Inc. Generic USB Joystick </name>
138
139 <nasal>
140 <script>
141 var (mod1, mod2, mod3) = (0, 0, 0);
142 # These variables are used to emulate non-repeatable buttons when
143 # mod3 != 0.
144 var (button0_with_mod3, button1_with_mod3, button2_with_mod3,
145 button3_with_mod3) = (0, 0, 0, 0);
146 var initial_goal_heading_offset_deg =
147 getprop("/sim/current-view/goal-heading-offset-deg") or 0.0;
148 var initial_goal_pitch_offset_deg =
149 getprop("/sim/current-view/goal-pitch-offset-deg") or 0.0;
150 </script>
151 </nasal>
152
153 <axis n="0">
154 <desc>Aileron</desc>
155 <binding>
156 <command>property-scale</command>
157 <property>/controls/flight/aileron</property>
158 <!-- I need the following offset when the joypad is in analog mode. -->
159 <offset type="double">-0.01028</offset>
160 <factor type="double">0.5</factor>
161 </binding>
162 </axis>
163
164 <axis n="1">
165 <desc>Elevator</desc>
166 <binding>
167 <command>property-scale</command>
168 <property>/controls/flight/elevator</property>
169 <!-- I need the following offset when the joypad is in analog mode. -->
170 <offset type="double">-0.01028</offset>
171 <factor type="double">-0.5</factor>
172 </binding>
173 </axis>
174
175 <axis n="3">
176 <desc>Rudder</desc>
177 <binding>
178 <command>property-scale</command>
179 <property>/controls/flight/rudder</property>
180 <!-- I need the following offset when the joypad is in analog mode. -->
181 <offset type="double">-0.01028</offset>
182 </binding>
183 </axis>
184
185 <axis n="4">
186 <desc>Throttle [mod3=0] / Mixture Control [mod3=1] / Elevator Trim [mod3=-1]</desc>
187 <high>
188 <repeatable type="bool">true</repeatable>
189 <binding>
190 <command>nasal</command>
191 <script>
192 if (mod3 == 0) {
193 controls.adjThrottle(-1.0);
194 } elsif (mod3 == 1) {
195 controls.adjMixture(-1);
196 } else {
197 setprop("/controls/flight/elevator-trim",
198 -0.001 + getprop("/controls/flight/elevator-trim"));
199 }
200 </script>
201 </binding>
202 </high>
203 <low>
204 <repeatable type="bool">true</repeatable>
205 <binding>
206 <command>nasal</command>
207 <script>
208 if (mod3 == 0) {
209 controls.adjThrottle(1.0);
210 } elsif (mod3 == 1) {
211 controls.adjMixture(1);
212 } else {
213 setprop("/controls/flight/elevator-trim",
214 0.001 + getprop("/controls/flight/elevator-trim"));
215 }
216 </script>
217 </binding>
218 </low>
219 </axis>
220
221 <axis n="5">
222 <name>mod3_switch</name>
223 <desc>Switch mod3 between the values -1, 0, 1</desc>
224 <binding>
225 <command>nasal</command>
226 <script>
227 mod3 = cmdarg().getNode("setting").getValue();
228 # gui.popupTip("DragonRise.mod3 = " ~ mod3, 2);
229 </script>
230 </binding>
231 </axis>
232
233 <axis n="6">
234 <name>mod1_mod2_toggle</name>
235 <desc>Toggle mod1 and mod2</desc>
236 <low>
237 <binding>
238 <command>nasal</command>
239 <script>
240 mod1 = !mod1;
241 gui.popupTip("DragonRise.mod1 = " ~ mod1, 2);
242 </script>
243 </binding>
244 </low>
245 <high>
246 <binding>
247 <command>nasal</command>
248 <script>
249 mod2 = !mod2;
250 gui.popupTip("DragonRise.mod2 = " ~ mod2, 2);
251 </script>
252 </binding>
253 </high>
254 </axis>
255
256 <button n="0">
257 <desc>View Up [mod3=0] / Select first engine [mod3=1] / Flaps Up [mod3=-1]</desc>
258 <repeatable type="bool">true</repeatable>
259 <binding>
260 <command>nasal</command>
261 <script>
262 if (mod3 == 0) {
263 setprop("/sim/current-view/goal-pitch-offset-deg",
264 1.0 + getprop("/sim/current-view/goal-pitch-offset-deg"));
265 return;
266 }
267
268 # Emulate a non-repeatable button for mod3 != 0
269 if (button0_with_mod3)
270 return;
271
272 button0_with_mod3 = 1;
273
274 if (mod3 == -1) {
275 controls.flapsDown(-1);
276 } else {
277 controls.selectEngine(0);
278 }
279 </script>
280 </binding>
281 <mod-up>
282 <binding>
283 <command>nasal</command>
284 <script>
285 button0_with_mod3 = 0;
286 </script>
287 </binding>
288 </mod-up>
289 </button>
290
291 <button n="1">
292 <desc>View Right / Brake Right [mod3=-1] / Select second engine [mod3=1] / Trigger1 [mod3=0 and mod1]</desc>
293 <repeatable type="bool">true</repeatable>
294 <binding>
295 <command>nasal</command>
296 <script>
297 if (mod3 == 0) {
298 if (mod1) {
299 # This seems the most common for "trigger"
300 setprop("/controls/armament/trigger1", 1);
301 # Many planes use this instead [also true for "trigger1"?]
302 setprop("/ai/submodels/trigger1", 1);
303 } else {
304 setprop("/sim/current-view/goal-heading-offset-deg",
305 -1.0 + getprop("/sim/current-view/goal-heading-offset-deg"));
306 }
307
308 return;
309 }
310
311 # Emulate a non-repeatable button for mod3 != 0
312 if (button1_with_mod3)
313 return;
314
315 button1_with_mod3 = 1;
316
317 if (mod3 == -1) {
318 controls.applyBrakes(1, 1);
319 } else {
320 controls.selectEngine(1);
321 }
322 </script>
323 </binding>
324 <mod-up>
325 <binding>
326 <command>nasal</command>
327 <script>
328 button1_with_mod3 = 0;
329
330 controls.applyBrakes(0, 1);
331 # This seems the most common for "trigger"
332 setprop("/controls/armament/trigger1", 0);
333 # Many planes use this instead [also true for "trigger1"?]
334 setprop("/ai/submodels/trigger1", 0);
335 </script>
336 </binding>
337 </mod-up>
338 </button>
339
340 <button n="2">
341 <desc>View Down [mod3=0] / Select third engine [mod3=1] / Flaps Down [mod3=-1]</desc>
342 <repeatable type="bool">true</repeatable>
343 <binding>
344 <command>nasal</command>
345 <script>
346 if (mod3 == 0) {
347 setprop("/sim/current-view/goal-pitch-offset-deg",
348 -1.0 + getprop("/sim/current-view/goal-pitch-offset-deg"));
349
350 return;
351 }
352
353 # Emulate a non-repeatable button for mod3 != 0
354 if (button2_with_mod3)
355 return;
356
357 button2_with_mod3 = 1;
358
359 if (mod3 == -1) {
360 controls.flapsDown(1);
361 } else {
362 controls.selectEngine(2);
363 }
364 </script>
365 </binding>
366 <mod-up>
367 <binding>
368 <command>nasal</command>
369 <script>
370 button2_with_mod3 = 0;
371 </script>
372 </binding>
373 </mod-up>
374 </button>
375
376 <button n="3">
377 <desc>View Left / Brake Left [mod3=-1] / Select fourth engine [mod3=1] / Trigger [mod3=0 and mod1]</desc>
378 <repeatable type="bool">true</repeatable>
379 <binding>
380 <command>nasal</command>
381 <script>
382 if (mod3 == 0) {
383 if (mod1) {
384 # This seems the most common
385 setprop("/controls/armament/trigger", 1);
386 # Many planes use this instead
387 setprop("/ai/submodels/trigger", 1);
388 } else {
389 setprop("/sim/current-view/goal-heading-offset-deg",
390 1.0 + getprop("/sim/current-view/goal-heading-offset-deg"));
391 }
392
393 return;
394 }
395
396 # Emulate a non-repeatable button for mod3 != 0
397 if (button3_with_mod3)
398 return;
399
400 button3_with_mod3 = 1;
401
402 if (mod3 == -1) {
403 controls.applyBrakes(1, -1);
404 } else {
405 controls.selectEngine(3);
406 }
407 </script>
408 </binding>
409 <mod-up>
410 <binding>
411 <command>nasal</command>
412 <script>
413 button3_with_mod3 = 0;
414 controls.applyBrakes(0, -1);
415
416 # This seems the most common
417 setprop("/controls/armament/trigger", 0);
418 # Many planes use this instead
419 setprop("/ai/submodels/trigger", 0);
420 </script>
421 </binding>
422 </mod-up>
423 </button>
424
425 <button n="4">
426 <desc>View Cycle (backward)</desc>
427 <repeatable type="bool">false</repeatable>
428 <binding>
429 <command>nasal</command>
430 <script>view.stepView(-1)</script>
431 </binding>
432 </button>
433
434 <button n="5">
435 <desc>View Cycle (forward)</desc>
436 <repeatable type="bool">false</repeatable>
437 <binding>
438 <command>nasal</command>
439 <script>view.stepView(1)</script>
440 </binding>
441 </button>
442
443 <button n="6">
444 <desc>View Decrease</desc>
445 <repeatable type="bool">true</repeatable>
446 <binding>
447 <command>nasal</command>
448 <script>view.decrease(0.75)</script>
449 </binding>
450 </button>
451
452 <button n="7">
453 <desc>View Increase</desc>
454 <repeatable type="bool">true</repeatable>
455 <binding>
456 <command>nasal</command>
457 <script>view.increase(0.75)</script>
458 </binding>
459 </button>
460
461 <button n="8">
462 <desc>Brakes [mod3=0] / Aileron and Rudder Dance [mod3=-1]</desc>
463 <binding>
464 <command>nasal</command>
465 <script>
466 if (mod3 == -1) {
467 interpolate("/controls/flight/aileron",
468 -0.5, 1, 0.5, 1, -0.5, 1, 0.5, 1, -0.5, 1, 0.5, 1,
469 -0.5, 1, 0.5, 1);
470 interpolate("/controls/flight/rudder",
471 -0.5, 1, 0.5, 1, -0.5, 1, 0.5, 1, -0.5, 1, 0.5, 1,
472 -0.5, 1, 0.5, 1);
473 }
474 elsif (mod3 == 0) {
475 controls.applyBrakes(1);
476 }
477 </script>
478 </binding>
479 <mod-up>
480 <binding>
481 <command>nasal</command>
482 <script>controls.applyBrakes(0)</script>
483 </binding>
484 </mod-up>
485 </button>
486
487 <button n="9">
488 <desc>Select Initial View and Recenter [mod3=0] / Reset Zoom to Default [mod3=-1] / Select all engines [mod3=1]</desc>
489 <binding>
490 <command>nasal</command>
491 <script>
492 if (mod3 == -1) {
493 setprop("/sim/current-view/field-of-view",
494 getprop("/sim/view/config/default-field-of-view-deg"));
495 } elsif (mod3 == 1) {
496 controls.selectAllEngines();
497 } else {
498 setprop("/sim/current-view/view-number", 0);
499 setprop("/sim/current-view/goal-heading-offset-deg",
500 initial_goal_heading_offset_deg);
501 setprop("/sim/current-view/goal-pitch-offset-deg",
502 initial_goal_pitch_offset_deg);
503 }
504 </script>
505 </binding>
506 </button>
507
508 </PropertyList>
509
510 <!-- end of generic.xml -->