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

            
3
<PropertyList>
4
  <nasal>
5
    <script><![CDATA[
6
      var skipFlightControls = props.globals.getNode("/sim/mouse/skip-flight-controls-mode");
7
      setlistener("/sim/signals/fdm-initilized", func {
8
          skipFlightControls.setBoolValue(1);
9
          print("JOYSTICK set mouse flight control OFF: ", skipFlightControls.getValue());
10
      }, 1 );
11
      setlistener("/sim/signals/save", func {
12
          skipFlightControls.setBoolValue(0);
13
          print("JOYSTICK save mouse flight control ON: ", skipFlightControls.getValue());
14
      } );
15

            
16
      # determine Nasal namespace for this joystick
17
      # stored in js[0]
18
      string.scanf(cmdarg().getNode("module").getValue(), "__js%u", var js = []);
19

            
20
      # array with prop path for each button status
21
      var pressed_button = [];
22
      for (var i = 0; i < 12; i += 1)
23
        append(pressed_button, "/devices/status/joysticks/joystick[" ~ js[0] ~ "]/button[" ~ i ~ "]");
24

            
25
      var previousMouseMode = 0;
26
      var locked_view = 0;
27

            
28
      var chinese_hat = func (heading, pitch) {
29
        if (getprop(pressed_button[0])) {
30
          if    (pitch   > 0) view.decrease();
31
          elsif (pitch   < 0) view.increase();
32
          elsif (heading > 0){view.resetViewDir();view.resetFOV();}
33
          elsif (heading < 0) view.resetFOV();
34
        }
35
        elsif (getprop(pressed_button[10])) {
36
          if (pitch)
37
            controls.elevatorTrim(pitch);
38
          else
39
            controls.rudderTrim(heading);
40
        }
41
        elsif (getprop(pressed_button[11]) and heading) {
42
          controls.aileronTrim(heading);
43
        }
44
        else {
45
          if (heading) {
46
            fgcommand("property-adjust", {
47
              property : "/sim/current-view/goal-heading-offset-deg",
48
              step : 2.0 * heading
49
            });
50
          }
51
          elsif (pitch) {
52
            fgcommand("property-adjust", {
53
              property : "/sim/current-view/goal-pitch-offset-deg",
54
              step : 2.0 * pitch
55
            });
56
          }
57
        }
58
      }
59

            
60
      var addSelectedEngine = func (i) {
61
        controls.engines[i].selected.setBoolValue(1);
62
        printf("engine %d added to joystick controls", i);
63
        gui.popupTip("engine " ~ i ~ " joystick controlled");
64
      }
65

            
66
      var removeSelectedEngine = func (i) {
67
        controls.engines[i].selected.setBoolValue(0);
68
        printf("engine %d removed from joystick controls", i);
69
        gui.popupTip("engine " ~ i ~ " joystick uncontrolled");
70
      }
71

            
72
      # key = button identifier as displayed on joystick
73
      joystick_button = {
74
        2 : func (pressed) {
75
          if (pressed) {
76
            if (getprop("/sim/current-view/view-number") > 1 or locked_view)
77
              return;
78
            previousMouseMode = getprop("/devices/status/mice/mouse[0]/mode");
79
            setprop("/devices/status/mice/mouse[0]/mode", 2);
80
          }
81
          elsif (getprop(pressed_button[0])) {
82
            locked_view = 1;
83
            return;
84
          }
85
          else {
86
            locked_view = 0;
87
            setprop("/devices/status/mice/mouse[0]/mode", previousMouseMode);
88
          }
89
          setprop("/sim/current-view/view-number", pressed);
90
        },
91

            
92
        3 : func (pressed) {
93
          controls.applyBrakes(pressed)
94
        },
95

            
add PTT
Sébastien MARQUE authored on 2020-11-15
96
        4 : func (pressed) {
97
          if (pressed) {
98
            var comm = getprop(pressed_button[0]) + 1;
99
            controls.ptt(comm);
100
            gui.popupTip("PTT COMM " ~ comm);
101
          }
102
          else {
103
            controls.ptt(0);
104
            gui.popupTip("PTT COMM ends", 0.5);
105
          }
106

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

            
109
        5 : func {
add QNH setting
Sébastien MARQUE authored on 2020-11-15
110
          if (getprop(pressed_button[0]))
111
            fgcommand("property-adjust", {
112
              property: "/instrumentation/altimeter/setting-inhg",
113
              step: 0.01
114
            });
115
          else
116
            controls.flapsDown(1)
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
117
        },
118

            
119
        6 : func {
add QNH setting
Sébastien MARQUE authored on 2020-11-15
120
          if (getprop(pressed_button[0]))
121
            fgcommand("property-adjust", {
122
              property: "/instrumentation/altimeter/setting-inhg",
123
              step: -0.01
124
            });
125
          elsif (getprop(pressed_button[10])) {
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
126
            for (var i = 0; i < 4; i += 1)
127
              controls.engines[i].selected.setBoolValue(1);
128
            printf("all engines added to joystick controls");
129
            gui.popupTip("joystick controls all engines");
130
          }
131
          elsif (getprop(pressed_button[11])) {
132
            for (var i = 0; i < 4; i += 1)
133
              controls.engines[i].selected.setBoolValue(0);
134
            printf("joystick controls no engines", i);
135
            gui.popupTip("joystick controls no engine");
136
          }
137
          else
138
            controls.flapsDown(-1)
139
        },
140

            
141
        7 : func {
142
          if    (getprop(pressed_button[10])) addSelectedEngine(2);
143
          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
144
          else controls.adjMixture(1);
145
        },
146

            
147
        8 : func {
148
          if    (getprop(pressed_button[10])) addSelectedEngine(3);
149
          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
150
          else controls.adjMixture(-1);
151
        },
152

            
153
        9 : func {
154
          if    (getprop(pressed_button[10])) addSelectedEngine(1);
155
          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
156
          else controls.adjPropeller(1);
157
        },
158

            
159
        10 : func {
160
          if    (getprop(pressed_button[10])) addSelectedEngine(0);
161
          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
162
          else controls.adjPropeller(-1);
163
        },
164
      }
165
    ]]></script>
166
  </nasal>
167

            
168
  <name type="string">T.Flight Stick X</name>
169
  <name type="string">Thrustmaster T.Flight Stick X</name>
170

            
171
  <axis n="0">
172
    <desc>Aileron</desc>
173
    <binding>
174
      <command>property-scale</command>
175
      <property>/controls/flight/aileron</property>
176
      <squared type="bool">true</squared>
177
    </binding>
178
  </axis>
179

            
180
  <axis n="1">
181
    <desc>Elevator</desc>
182
    <binding>
183
      <command>property-scale</command>
184
      <property>/controls/flight/elevator</property>
185
      <factor type="double">-1.0</factor>
186
      <squared type="bool">true</squared>
187
    </binding>
188
  </axis>
189

            
190
  <axis>
191
    <number>
192
      <windows>2</windows>
193
      <unix>3</unix>
194
    </number>
195
    <desc>Increase/Reduce Throttle</desc>
196
    <binding>
197
      <command>nasal</command>
198
      <script>controls.throttleAxis()</script>
199
    </binding>
200
  </axis>
201

            
202
  <axis>
203
    <number>
204
      <windows>3</windows>
205
      <unix>2</unix>
206
    </number>
207
    <desc>Rudder Left/Right</desc>
208
    <binding>
209
      <command>property-scale</command>
210
      <property>/controls/flight/rudder</property>
211
      <factor type="double">1.0</factor>
212
    </binding>
213
  </axis>
214

            
215
  <axis>
216
    <number>
217
      <windows>6</windows>
218
      <unix>4</unix>
219
    </number>
220
    <desc>View Direction | reset FoV | reset view direction</desc>
221
    <low>
222
      <repeatable>true</repeatable>
223
      <binding>
224
        <command>nasal</command>
225
        <script>chinese_hat(1, 0)</script>
226
      </binding>
227
    </low>
228
    <high>
229
      <repeatable>true</repeatable>
230
      <binding>
231
        <command>nasal</command>
232
        <script>chinese_hat(-1, 0)</script>
233
      </binding>
234
    </high>
235
  </axis>
236

            
237
  <axis>
238
    <number>
239
      <windows>7</windows>
240
      <unix>5</unix>
241
    </number>
242
    <desc>Orientation up or down / Increase or decrease FoV</desc>
243
    <low>
244
      <repeatable>true</repeatable>
245
      <binding>
246
        <command>nasal</command>
247
        <script>chinese_hat(0, 1)</script>
248
      </binding>
249
    </low>
250
    <high>
251
      <repeatable>true</repeatable>
252
      <binding>
253
        <command>nasal</command>
254
        <script>chinese_hat(0, -1)</script>
255
      </binding>
256
    </high>
257
  </axis>
258

            
259
  <button n="1">
260
    <desc>Swap first and second views</desc>
261
    <binding>
262
      <command>nasal</command>
263
      <script>joystick_button[2](1)</script>
264
    </binding>
265
    <mod-up>
266
      <binding>
267
        <command>nasal</command>
268
        <script>joystick_button[2](0)</script>
269
      </binding>
270
    </mod-up>
271
  </button>
272

            
273
  <button n="2">
274
    <desc>Apply brakes</desc>
275
    <binding>
276
      <command>nasal</command>
277
      <script>joystick_button[3](0)</script>
278
    </binding>
279
    <mod-up>
280
      <binding>
281
        <command>nasal</command>
282
        <script>joystick_button[3](1)</script>
283
      </binding>
284
    </mod-up>
285
  </button>
286

            
add PTT
Sébastien MARQUE authored on 2020-11-15
287
  <button n="3">
288
    <desc>PTT - Push To Talk (via FGCom)</desc>
289
    <binding>
290
      <command>nasal</command>
291
      <script>joystick_button[4](1)</script>
292
    </binding>
293
    <mod-up>
294
      <binding>
295
        <command>nasal</command>
296
        <script>joystick_button[4](0)</script>
297
      </binding>
298
    </mod-up>
299
  </button>
300

            
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
301
  <button n="4">
302
    <desc>Extend Flaps Incrementally</desc>
303
    <repeatable>false</repeatable>
304
    <binding>
305
      <command>nasal</command>
306
      <script>joystick_button[5]()</script>
307
    </binding>
308
  </button>
309

            
310
  <button n="5">
311
    <desc>Retract Flaps Incrementally</desc>
312
    <repeatable>false</repeatable>
313
    <binding>
314
      <command>nasal</command>
315
      <script>joystick_button[6]()</script>
316
    </binding>
317
  </button>
318

            
319
  <button n="6">
320
    <desc>Handle mixture | add or remove engine 0</desc>
321
    <repeatable>true</repeatable>
322
    <binding>
323
      <command>nasal</command>
324
      <script>joystick_button[7]()</script>
325
    </binding>
326
  </button>
327

            
328
  <button n="7">
329
    <desc>Handle mixture | add or remove engine 1</desc>
330
    <repeatable>true</repeatable>
331
    <binding>
332
      <command>nasal</command>
333
      <script>joystick_button[8]()</script>
334
    </binding>
335
  </button>
336

            
337
  <button n="8">
338
    <desc>Handle mixture | add or remove engine 2</desc>
339
    <repeatable>true</repeatable>
340
    <binding>
341
      <command>nasal</command>
342
      <script>joystick_button[9]()</script>
343
    </binding>
344
  </button>
345

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

            
355
</PropertyList>
356

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