config / .fgfs / Input / Joysticks / T-Flight-Stick-X.xml /
Newer Older
346 lines | 9.621kb
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 {
110
          controls.flapsDown(1)
111
        },
112

            
113
        6 : func {
114
          if    (getprop(pressed_button[10])) {
115
            for (var i = 0; i < 4; i += 1)
116
              controls.engines[i].selected.setBoolValue(1);
117
            printf("all engines added to joystick controls");
118
            gui.popupTip("joystick controls all engines");
119
          }
120
          elsif (getprop(pressed_button[11])) {
121
            for (var i = 0; i < 4; i += 1)
122
              controls.engines[i].selected.setBoolValue(0);
123
            printf("joystick controls no engines", i);
124
            gui.popupTip("joystick controls no engine");
125
          }
126
          else
127
            controls.flapsDown(-1)
128
        },
129

            
130
        7 : func {
131
          if    (getprop(pressed_button[10])) addSelectedEngine(2);
132
          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
133
          else controls.adjMixture(1);
134
        },
135

            
136
        8 : func {
137
          if    (getprop(pressed_button[10])) addSelectedEngine(3);
138
          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
139
          else controls.adjMixture(-1);
140
        },
141

            
142
        9 : func {
143
          if    (getprop(pressed_button[10])) addSelectedEngine(1);
144
          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
145
          else controls.adjPropeller(1);
146
        },
147

            
148
        10 : func {
149
          if    (getprop(pressed_button[10])) addSelectedEngine(0);
150
          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
151
          else controls.adjPropeller(-1);
152
        },
153
      }
154
    ]]></script>
155
  </nasal>
156

            
157
  <name type="string">T.Flight Stick X</name>
158
  <name type="string">Thrustmaster T.Flight Stick X</name>
159

            
160
  <axis n="0">
161
    <desc>Aileron</desc>
162
    <binding>
163
      <command>property-scale</command>
164
      <property>/controls/flight/aileron</property>
165
      <squared type="bool">true</squared>
166
    </binding>
167
  </axis>
168

            
169
  <axis n="1">
170
    <desc>Elevator</desc>
171
    <binding>
172
      <command>property-scale</command>
173
      <property>/controls/flight/elevator</property>
174
      <factor type="double">-1.0</factor>
175
      <squared type="bool">true</squared>
176
    </binding>
177
  </axis>
178

            
179
  <axis>
180
    <number>
181
      <windows>2</windows>
182
      <unix>3</unix>
183
    </number>
184
    <desc>Increase/Reduce Throttle</desc>
185
    <binding>
186
      <command>nasal</command>
187
      <script>controls.throttleAxis()</script>
188
    </binding>
189
  </axis>
190

            
191
  <axis>
192
    <number>
193
      <windows>3</windows>
194
      <unix>2</unix>
195
    </number>
196
    <desc>Rudder Left/Right</desc>
197
    <binding>
198
      <command>property-scale</command>
199
      <property>/controls/flight/rudder</property>
200
      <factor type="double">1.0</factor>
201
    </binding>
202
  </axis>
203

            
204
  <axis>
205
    <number>
206
      <windows>6</windows>
207
      <unix>4</unix>
208
    </number>
209
    <desc>View Direction | reset FoV | reset view direction</desc>
210
    <low>
211
      <repeatable>true</repeatable>
212
      <binding>
213
        <command>nasal</command>
214
        <script>chinese_hat(1, 0)</script>
215
      </binding>
216
    </low>
217
    <high>
218
      <repeatable>true</repeatable>
219
      <binding>
220
        <command>nasal</command>
221
        <script>chinese_hat(-1, 0)</script>
222
      </binding>
223
    </high>
224
  </axis>
225

            
226
  <axis>
227
    <number>
228
      <windows>7</windows>
229
      <unix>5</unix>
230
    </number>
231
    <desc>Orientation up or down / Increase or decrease FoV</desc>
232
    <low>
233
      <repeatable>true</repeatable>
234
      <binding>
235
        <command>nasal</command>
236
        <script>chinese_hat(0, 1)</script>
237
      </binding>
238
    </low>
239
    <high>
240
      <repeatable>true</repeatable>
241
      <binding>
242
        <command>nasal</command>
243
        <script>chinese_hat(0, -1)</script>
244
      </binding>
245
    </high>
246
  </axis>
247

            
248
  <button n="1">
249
    <desc>Swap first and second views</desc>
250
    <binding>
251
      <command>nasal</command>
252
      <script>joystick_button[2](1)</script>
253
    </binding>
254
    <mod-up>
255
      <binding>
256
        <command>nasal</command>
257
        <script>joystick_button[2](0)</script>
258
      </binding>
259
    </mod-up>
260
  </button>
261

            
262
  <button n="2">
263
    <desc>Apply brakes</desc>
264
    <binding>
265
      <command>nasal</command>
266
      <script>joystick_button[3](0)</script>
267
    </binding>
268
    <mod-up>
269
      <binding>
270
        <command>nasal</command>
271
        <script>joystick_button[3](1)</script>
272
      </binding>
273
    </mod-up>
274
  </button>
275

            
add PTT
Sébastien MARQUE authored on 2020-11-15
276
  <button n="3">
277
    <desc>PTT - Push To Talk (via FGCom)</desc>
278
    <binding>
279
      <command>nasal</command>
280
      <script>joystick_button[4](1)</script>
281
    </binding>
282
    <mod-up>
283
      <binding>
284
        <command>nasal</command>
285
        <script>joystick_button[4](0)</script>
286
      </binding>
287
    </mod-up>
288
  </button>
289

            
UNIX end of line + some fixe...
Sébastien MARQUE authored on 2020-11-14
290
  <button n="4">
291
    <desc>Extend Flaps Incrementally</desc>
292
    <repeatable>false</repeatable>
293
    <binding>
294
      <command>nasal</command>
295
      <script>joystick_button[5]()</script>
296
    </binding>
297
  </button>
298

            
299
  <button n="5">
300
    <desc>Retract Flaps Incrementally</desc>
301
    <repeatable>false</repeatable>
302
    <binding>
303
      <command>nasal</command>
304
      <script>joystick_button[6]()</script>
305
    </binding>
306
  </button>
307

            
308
  <button n="6">
309
    <desc>Handle mixture | add or remove engine 0</desc>
310
    <repeatable>true</repeatable>
311
    <binding>
312
      <command>nasal</command>
313
      <script>joystick_button[7]()</script>
314
    </binding>
315
  </button>
316

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

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

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

            
344
</PropertyList>
345

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