config / .fgfs / Input / Joysticks / T-Flight-Stick-X.xml /
Newer Older
435 lines | 13.969kb
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
1
<?xml version="1.0"?>
2

            
add comments for usage help
Sébastien MARQUE authored on 2020-11-15
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

            
ajoute l'affichage des POI
Sébastien MARQUE authored on 2022-03-04
13
Button 2  | heli view     | permanent heli view | show/hide pins      | declutter pins
add comments for usage help
Sébastien MARQUE authored on 2020-11-15
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   |                     | control engine 2    | uncontrol engine 2
19
Button 8  | dec mixture   |                     | control engine 3    | uncontrol engine 3
20
Button 9  | inc proppitch |                     | control engine 1    | uncontrol engine 1
21
Button 10 | dec proppitch |                     | 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

            
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
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) {
invert aileron trim directio...
Sébastien MARQUE authored on 2021-02-21
68
          controls.aileronTrim(-heading);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
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) {
ajoute l'affichage des POI
Sébastien MARQUE authored on 2022-03-04
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
            elsif (getprop(pressed_button[0])) {
152
              locked_view = 1;
153
              setprop("/sim/current-view/view-number", pressed);
154
            }
155
            else {
156
              locked_view = 0;
157
              setprop("/devices/status/mice/mouse[0]/mode", previousMouseMode);
158
              setprop("/sim/current-view/view-number", pressed);
159
            }
160
          }
161
          else {
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
162
            if (getprop("/sim/current-view/view-number") > 1 or locked_view)
163
              return;
164
            previousMouseMode = getprop("/devices/status/mice/mouse[0]/mode");
165
            setprop("/devices/status/mice/mouse[0]/mode", 2);
ajoute l'affichage des POI
Sébastien MARQUE authored on 2022-03-04
166
            setprop("/sim/current-view/view-number", pressed);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
167
          }
168
        },
169

            
170
        3 : func (pressed) {
171
          controls.applyBrakes(pressed)
172
        },
173

            
add PTT
Sébastien MARQUE authored on 2020-11-15
174
        4 : func (pressed) {
175
          if (pressed) {
176
            var comm = getprop(pressed_button[0]) + 1;
177
            controls.ptt(comm);
178
            gui.popupTip("PTT COMM " ~ comm);
179
          }
180
          else {
181
            controls.ptt(0);
182
            gui.popupTip("PTT COMM ends", 0.5);
183
          }
184

            
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
185
        },
186

            
187
        5 : func {
add QNH setting
Sébastien MARQUE authored on 2020-11-15
188
          if (getprop(pressed_button[0]))
189
            fgcommand("property-adjust", {
190
              property: "/instrumentation/altimeter/setting-inhg",
191
              step: 0.01
192
            });
193
          else
194
            controls.flapsDown(1)
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
195
        },
196

            
197
        6 : func {
add QNH setting
Sébastien MARQUE authored on 2020-11-15
198
          if (getprop(pressed_button[0]))
199
            fgcommand("property-adjust", {
200
              property: "/instrumentation/altimeter/setting-inhg",
201
              step: -0.01
202
            });
203
          elsif (getprop(pressed_button[10])) {
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
204
            for (var i = 0; i < 4; i += 1)
205
              controls.engines[i].selected.setBoolValue(1);
206
            printf("all engines added to joystick controls");
207
            gui.popupTip("joystick controls all engines");
208
          }
209
          elsif (getprop(pressed_button[11])) {
210
            for (var i = 0; i < 4; i += 1)
211
              controls.engines[i].selected.setBoolValue(0);
212
            printf("joystick controls no engines", i);
213
            gui.popupTip("joystick controls no engine");
214
          }
215
          else
216
            controls.flapsDown(-1)
217
        },
218

            
219
        7 : func {
220
          if    (getprop(pressed_button[10])) addSelectedEngine(2);
221
          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
finer adjust for mixture and...
Sébastien MARQUE authored on 2021-02-21
222
          else controls.adjMixture(-0.1);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
223
        },
224

            
225
        8 : func {
226
          if    (getprop(pressed_button[10])) addSelectedEngine(3);
227
          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
finer adjust for mixture and...
Sébastien MARQUE authored on 2021-02-21
228
          else controls.adjMixture(0.1);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
229
        },
230

            
231
        9 : func {
232
          if    (getprop(pressed_button[10])) addSelectedEngine(1);
233
          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
finer adjust for mixture and...
Sébastien MARQUE authored on 2021-02-21
234
          else controls.adjPropeller(0.1);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
235
        },
236

            
237
        10 : func {
238
          if    (getprop(pressed_button[10])) addSelectedEngine(0);
239
          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
finer adjust for mixture and...
Sébastien MARQUE authored on 2021-02-21
240
          else controls.adjPropeller(-0.1);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
241
        },
242
      }
243
    ]]></script>
244
  </nasal>
245

            
246
  <name type="string">T.Flight Stick X</name>
247
  <name type="string">Thrustmaster T.Flight Stick X</name>
248

            
249
  <axis n="0">
250
    <desc>Aileron</desc>
251
    <binding>
252
      <command>property-scale</command>
253
      <property>/controls/flight/aileron</property>
254
      <squared type="bool">true</squared>
255
    </binding>
256
  </axis>
257

            
258
  <axis n="1">
259
    <desc>Elevator</desc>
260
    <binding>
261
      <command>property-scale</command>
262
      <property>/controls/flight/elevator</property>
263
      <factor type="double">-1.0</factor>
264
      <squared type="bool">true</squared>
265
    </binding>
266
  </axis>
267

            
268
  <axis>
269
    <number>
270
      <windows>2</windows>
271
      <unix>3</unix>
272
    </number>
273
    <desc>Increase/Reduce Throttle</desc>
274
    <binding>
275
      <command>nasal</command>
276
      <script>controls.throttleAxis()</script>
277
    </binding>
278
  </axis>
279

            
280
  <axis>
281
    <number>
282
      <windows>3</windows>
283
      <unix>2</unix>
284
    </number>
285
    <desc>Rudder Left/Right</desc>
286
    <binding>
287
      <command>property-scale</command>
288
      <property>/controls/flight/rudder</property>
289
      <factor type="double">1.0</factor>
290
    </binding>
291
  </axis>
292

            
293
  <axis>
294
    <number>
295
      <windows>6</windows>
296
      <unix>4</unix>
297
    </number>
298
    <desc>View Direction | reset FoV | reset view direction</desc>
299
    <low>
300
      <repeatable>true</repeatable>
301
      <binding>
302
        <command>nasal</command>
303
        <script>chinese_hat(1, 0)</script>
304
      </binding>
305
    </low>
306
    <high>
307
      <repeatable>true</repeatable>
308
      <binding>
309
        <command>nasal</command>
310
        <script>chinese_hat(-1, 0)</script>
311
      </binding>
312
    </high>
313
  </axis>
314

            
315
  <axis>
316
    <number>
317
      <windows>7</windows>
318
      <unix>5</unix>
319
    </number>
320
    <desc>Orientation up or down / Increase or decrease FoV</desc>
321
    <low>
322
      <repeatable>true</repeatable>
323
      <binding>
324
        <command>nasal</command>
325
        <script>chinese_hat(0, 1)</script>
326
      </binding>
327
    </low>
328
    <high>
329
      <repeatable>true</repeatable>
330
      <binding>
331
        <command>nasal</command>
332
        <script>chinese_hat(0, -1)</script>
333
      </binding>
334
    </high>
335
  </axis>
336

            
337
  <button n="1">
add comment
Sébastien MARQUE authored on 2022-03-06
338
    <desc>Swap first and second views | pins POIs</desc>
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
339
    <binding>
340
      <command>nasal</command>
341
      <script>joystick_button[2](1)</script>
342
    </binding>
343
    <mod-up>
344
      <binding>
345
        <command>nasal</command>
346
        <script>joystick_button[2](0)</script>
347
      </binding>
348
    </mod-up>
349
  </button>
350

            
351
  <button n="2">
352
    <desc>Apply brakes</desc>
353
    <binding>
354
      <command>nasal</command>
355
      <script>joystick_button[3](0)</script>
356
    </binding>
357
    <mod-up>
358
      <binding>
359
        <command>nasal</command>
360
        <script>joystick_button[3](1)</script>
361
      </binding>
362
    </mod-up>
363
  </button>
364

            
add PTT
Sébastien MARQUE authored on 2020-11-15
365
  <button n="3">
366
    <desc>PTT - Push To Talk (via FGCom)</desc>
367
    <binding>
368
      <command>nasal</command>
369
      <script>joystick_button[4](1)</script>
370
    </binding>
371
    <mod-up>
372
      <binding>
373
        <command>nasal</command>
374
        <script>joystick_button[4](0)</script>
375
      </binding>
376
    </mod-up>
377
  </button>
378

            
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
379
  <button n="4">
380
    <desc>Extend Flaps Incrementally</desc>
381
    <repeatable>false</repeatable>
382
    <binding>
383
      <command>nasal</command>
384
      <script>joystick_button[5]()</script>
385
    </binding>
386
  </button>
387

            
388
  <button n="5">
389
    <desc>Retract Flaps Incrementally</desc>
390
    <repeatable>false</repeatable>
391
    <binding>
392
      <command>nasal</command>
393
      <script>joystick_button[6]()</script>
394
    </binding>
395
  </button>
396

            
397
  <button n="6">
398
    <desc>Handle mixture | add or remove engine 0</desc>
399
    <repeatable>true</repeatable>
400
    <binding>
401
      <command>nasal</command>
402
      <script>joystick_button[7]()</script>
403
    </binding>
404
  </button>
405

            
406
  <button n="7">
407
    <desc>Handle mixture | add or remove engine 1</desc>
408
    <repeatable>true</repeatable>
409
    <binding>
410
      <command>nasal</command>
411
      <script>joystick_button[8]()</script>
412
    </binding>
413
  </button>
414

            
415
  <button n="8">
correct comments
Sébastien MARQUE authored on 2021-02-13
416
    <desc>Handle prop-pitch | add or remove engine 2</desc>
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
417
    <repeatable>true</repeatable>
418
    <binding>
419
      <command>nasal</command>
420
      <script>joystick_button[9]()</script>
421
    </binding>
422
  </button>
423

            
424
  <button n="9">
correct comments
Sébastien MARQUE authored on 2021-02-13
425
    <desc>Handle prop-pitch | add or remove engine 3</desc>
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
426
    <repeatable>true</repeatable>
427
    <binding>
428
      <command>nasal</command>
429
      <script>joystick_button[10]()</script>
430
    </binding>
431
  </button>
432

            
433
</PropertyList>
434

            
435
<!-- end of T.Flight Stick X.xml -->