config / .fgfs / Input / Joysticks / T-Flight-Stick-X.xml /
Newer Older
383 lines | 11.572kb
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

            
13
Button 2  | heli view     | permanent heli view |                     |
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) {
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("/sim/current-view/view-number") > 1 or locked_view)
103
              return;
104
            previousMouseMode = getprop("/devices/status/mice/mouse[0]/mode");
105
            setprop("/devices/status/mice/mouse[0]/mode", 2);
106
          }
107
          elsif (getprop(pressed_button[0])) {
108
            locked_view = 1;
109
            return;
110
          }
111
          else {
112
            locked_view = 0;
113
            setprop("/devices/status/mice/mouse[0]/mode", previousMouseMode);
114
          }
115
          setprop("/sim/current-view/view-number", pressed);
116
        },
117

            
118
        3 : func (pressed) {
119
          controls.applyBrakes(pressed)
120
        },
121

            
add PTT
Sébastien MARQUE authored on 2020-11-15
122
        4 : func (pressed) {
123
          if (pressed) {
124
            var comm = getprop(pressed_button[0]) + 1;
125
            controls.ptt(comm);
126
            gui.popupTip("PTT COMM " ~ comm);
127
          }
128
          else {
129
            controls.ptt(0);
130
            gui.popupTip("PTT COMM ends", 0.5);
131
          }
132

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

            
135
        5 : func {
add QNH setting
Sébastien MARQUE authored on 2020-11-15
136
          if (getprop(pressed_button[0]))
137
            fgcommand("property-adjust", {
138
              property: "/instrumentation/altimeter/setting-inhg",
139
              step: 0.01
140
            });
141
          else
142
            controls.flapsDown(1)
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
143
        },
144

            
145
        6 : func {
add QNH setting
Sébastien MARQUE authored on 2020-11-15
146
          if (getprop(pressed_button[0]))
147
            fgcommand("property-adjust", {
148
              property: "/instrumentation/altimeter/setting-inhg",
149
              step: -0.01
150
            });
151
          elsif (getprop(pressed_button[10])) {
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
152
            for (var i = 0; i < 4; i += 1)
153
              controls.engines[i].selected.setBoolValue(1);
154
            printf("all engines added to joystick controls");
155
            gui.popupTip("joystick controls all engines");
156
          }
157
          elsif (getprop(pressed_button[11])) {
158
            for (var i = 0; i < 4; i += 1)
159
              controls.engines[i].selected.setBoolValue(0);
160
            printf("joystick controls no engines", i);
161
            gui.popupTip("joystick controls no engine");
162
          }
163
          else
164
            controls.flapsDown(-1)
165
        },
166

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

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

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

            
185
        10 : func {
186
          if    (getprop(pressed_button[10])) addSelectedEngine(0);
187
          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
finer adjust for mixture and...
Sébastien MARQUE authored on 2021-02-21
188
          else controls.adjPropeller(-0.1);
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
189
        },
190
      }
191
    ]]></script>
192
  </nasal>
193

            
194
  <name type="string">T.Flight Stick X</name>
195
  <name type="string">Thrustmaster T.Flight Stick X</name>
196

            
197
  <axis n="0">
198
    <desc>Aileron</desc>
199
    <binding>
200
      <command>property-scale</command>
201
      <property>/controls/flight/aileron</property>
202
      <squared type="bool">true</squared>
203
    </binding>
204
  </axis>
205

            
206
  <axis n="1">
207
    <desc>Elevator</desc>
208
    <binding>
209
      <command>property-scale</command>
210
      <property>/controls/flight/elevator</property>
211
      <factor type="double">-1.0</factor>
212
      <squared type="bool">true</squared>
213
    </binding>
214
  </axis>
215

            
216
  <axis>
217
    <number>
218
      <windows>2</windows>
219
      <unix>3</unix>
220
    </number>
221
    <desc>Increase/Reduce Throttle</desc>
222
    <binding>
223
      <command>nasal</command>
224
      <script>controls.throttleAxis()</script>
225
    </binding>
226
  </axis>
227

            
228
  <axis>
229
    <number>
230
      <windows>3</windows>
231
      <unix>2</unix>
232
    </number>
233
    <desc>Rudder Left/Right</desc>
234
    <binding>
235
      <command>property-scale</command>
236
      <property>/controls/flight/rudder</property>
237
      <factor type="double">1.0</factor>
238
    </binding>
239
  </axis>
240

            
241
  <axis>
242
    <number>
243
      <windows>6</windows>
244
      <unix>4</unix>
245
    </number>
246
    <desc>View Direction | reset FoV | reset view direction</desc>
247
    <low>
248
      <repeatable>true</repeatable>
249
      <binding>
250
        <command>nasal</command>
251
        <script>chinese_hat(1, 0)</script>
252
      </binding>
253
    </low>
254
    <high>
255
      <repeatable>true</repeatable>
256
      <binding>
257
        <command>nasal</command>
258
        <script>chinese_hat(-1, 0)</script>
259
      </binding>
260
    </high>
261
  </axis>
262

            
263
  <axis>
264
    <number>
265
      <windows>7</windows>
266
      <unix>5</unix>
267
    </number>
268
    <desc>Orientation up or down / Increase or decrease FoV</desc>
269
    <low>
270
      <repeatable>true</repeatable>
271
      <binding>
272
        <command>nasal</command>
273
        <script>chinese_hat(0, 1)</script>
274
      </binding>
275
    </low>
276
    <high>
277
      <repeatable>true</repeatable>
278
      <binding>
279
        <command>nasal</command>
280
        <script>chinese_hat(0, -1)</script>
281
      </binding>
282
    </high>
283
  </axis>
284

            
285
  <button n="1">
286
    <desc>Swap first and second views</desc>
287
    <binding>
288
      <command>nasal</command>
289
      <script>joystick_button[2](1)</script>
290
    </binding>
291
    <mod-up>
292
      <binding>
293
        <command>nasal</command>
294
        <script>joystick_button[2](0)</script>
295
      </binding>
296
    </mod-up>
297
  </button>
298

            
299
  <button n="2">
300
    <desc>Apply brakes</desc>
301
    <binding>
302
      <command>nasal</command>
303
      <script>joystick_button[3](0)</script>
304
    </binding>
305
    <mod-up>
306
      <binding>
307
        <command>nasal</command>
308
        <script>joystick_button[3](1)</script>
309
      </binding>
310
    </mod-up>
311
  </button>
312

            
add PTT
Sébastien MARQUE authored on 2020-11-15
313
  <button n="3">
314
    <desc>PTT - Push To Talk (via FGCom)</desc>
315
    <binding>
316
      <command>nasal</command>
317
      <script>joystick_button[4](1)</script>
318
    </binding>
319
    <mod-up>
320
      <binding>
321
        <command>nasal</command>
322
        <script>joystick_button[4](0)</script>
323
      </binding>
324
    </mod-up>
325
  </button>
326

            
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
327
  <button n="4">
328
    <desc>Extend Flaps Incrementally</desc>
329
    <repeatable>false</repeatable>
330
    <binding>
331
      <command>nasal</command>
332
      <script>joystick_button[5]()</script>
333
    </binding>
334
  </button>
335

            
336
  <button n="5">
337
    <desc>Retract Flaps Incrementally</desc>
338
    <repeatable>false</repeatable>
339
    <binding>
340
      <command>nasal</command>
341
      <script>joystick_button[6]()</script>
342
    </binding>
343
  </button>
344

            
345
  <button n="6">
346
    <desc>Handle mixture | add or remove engine 0</desc>
347
    <repeatable>true</repeatable>
348
    <binding>
349
      <command>nasal</command>
350
      <script>joystick_button[7]()</script>
351
    </binding>
352
  </button>
353

            
354
  <button n="7">
355
    <desc>Handle mixture | add or remove engine 1</desc>
356
    <repeatable>true</repeatable>
357
    <binding>
358
      <command>nasal</command>
359
      <script>joystick_button[8]()</script>
360
    </binding>
361
  </button>
362

            
363
  <button n="8">
correct comments
Sébastien MARQUE authored on 2021-02-13
364
    <desc>Handle prop-pitch | add or remove engine 2</desc>
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
365
    <repeatable>true</repeatable>
366
    <binding>
367
      <command>nasal</command>
368
      <script>joystick_button[9]()</script>
369
    </binding>
370
  </button>
371

            
372
  <button n="9">
correct comments
Sébastien MARQUE authored on 2021-02-13
373
    <desc>Handle prop-pitch | add or remove engine 3</desc>
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
374
    <repeatable>true</repeatable>
375
    <binding>
376
      <command>nasal</command>
377
      <script>joystick_button[10]()</script>
378
    </binding>
379
  </button>
380

            
381
</PropertyList>
382

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