config / .fgfs / Input / Joysticks / T-Flight-Stick-X.xml /
Newer Older
313 lines | 8.953kb
initial commit for TM T. Fli...
Sébastien MARQUE authored on 2020-11-13
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 swap_views = 
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
        var toAdd = [ i ];
62
        foreach(var e; controls.engines)
63
          if (e.selected.getValue() and e.index != i)
64
            append(toAdd, e.index);
65
        controls.selectEngines(1, toAdd);
66
        printf("engine %d added to joystick controls", i);
67
        gui.popupTip("engine " ~ i ~ " joystick controlled");
68
      }
69

            
70
      var removeSelectedEngine = func (i) {
71
        var toRemove = [ i ];
72
        foreach(var e; controls.engines)
73
          if (!(e.selected.getValue() and e.index == i))
74
            append(toRemove, e.index);
75
        controls.selectEngines(0, toRemove);
76
        printf("engine %d removed from joystick controls", i);
77
        gui.popupTip("engine " ~ i ~ " joystick uncontrolled");
78
      }
79
     
80
      # key = button identifier as displayed on joystick
81
      joystick_button = {
82
        2 : func (pressed) {
83
          if (pressed) {
84
            if (getprop("/sim/current-view/view-number") > 1)
85
              return;
86
            previousMouseMode = getprop("/devices/status/mice/mouse[0]/mode");
87
            setprop("/devices/status/mice/mouse[0]/mode", 2);
88
          }
89
          elsif (getprop(pressed_button[0]))
90
            return;
91
          else
92
            setprop("/devices/status/mice/mouse[0]/mode", previousMouseMode);
93
          setprop("/sim/current-view/view-number", pressed);
94
        },
95

            
96
        3 : func (pressed) {
97
          controls.applyBrakes(pressed)
98
        },
99

            
100
        4 : func {
101
        },
102

            
103
        5 : func {
104
          controls.flapsDown(1)
105
        },
106

            
107
        6 : func {
108
          controls.flapsDown(-1)
109
        },
110

            
111
        7 : func {
112
          if    (getprop(pressed_button[10])) addSelectedEngine(2);
113
          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
114
          else controls.adjMixture(1);
115
        },
116

            
117
        8 : func {
118
          if    (getprop(pressed_button[10])) addSelectedEngine(3);
119
          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
120
          else controls.adjMixture(-1);
121
        },
122

            
123
        9 : func {
124
          if    (getprop(pressed_button[10])) addSelectedEngine(1);
125
          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
126
          else controls.adjPropeller(1);
127
        },
128

            
129
        10 : func {
130
          if    (getprop(pressed_button[10])) addSelectedEngine(0);
131
          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
132
          else controls.adjPropeller(-1);
133
        },
134
      }
135
    ]]></script>
136
  </nasal>
137

            
138
  <name type="string">T.Flight Stick X</name>
139
  <name type="string">Thrustmaster T.Flight Stick X</name>
140

            
141
  <axis n="0">
142
    <desc>Aileron</desc>
143
    <binding>
144
      <command>property-scale</command>
145
      <property>/controls/flight/aileron</property>
146
      <squared type="bool">true</squared>
147
    </binding>
148
  </axis>
149

            
150
  <axis n="1">
151
    <desc>Elevator</desc>
152
    <binding>
153
      <command>property-scale</command>
154
      <property>/controls/flight/elevator</property>
155
      <factor type="double">-1.0</factor>
156
      <squared type="bool">true</squared>
157
    </binding>
158
  </axis>
159

            
160
  <axis>
161
    <number>
162
      <windows>2</windows>
163
      <unix>3</unix>
164
    </number>
165
    <desc>Increase/Reduce Throttle</desc>
166
    <binding>
167
      <command>nasal</command>
168
      <script>controls.throttleAxis()</script>
169
    </binding>
170
  </axis>
171

            
172
  <axis>
173
    <number>
174
      <windows>3</windows>
175
      <unix>2</unix>
176
    </number>
177
    <desc>Rudder Left/Right</desc>
178
    <binding>
179
      <command>property-scale</command>
180
      <property>/controls/flight/rudder</property>
181
      <factor type="double">1.0</factor>
182
    </binding>
183
  </axis>
184

            
185
  <axis>
186
    <number>
187
      <windows>6</windows>
188
      <unix>4</unix>
189
    </number>
190
    <desc>View Direction | reset FoV | reset view direction</desc>
191
    <low>
192
      <repeatable>true</repeatable>
193
      <binding>
194
        <command>nasal</command>
195
        <script>chinese_hat(1, 0)</script>
196
      </binding>
197
    </low>
198
    <high>
199
      <repeatable>true</repeatable>
200
      <binding>
201
        <command>nasal</command>
202
        <script>chinese_hat(-1, 0)</script>
203
      </binding>
204
    </high>
205
  </axis>
206

            
207
  <axis>
208
    <number>
209
      <windows>7</windows>
210
      <unix>5</unix>
211
    </number>
212
    <desc>Orientation up or down / Increase or decrease FoV</desc>
213
    <low>
214
      <repeatable>true</repeatable>
215
      <binding>
216
        <command>nasal</command>
217
        <script>chinese_hat(0, 1)</script>
218
      </binding>
219
    </low>
220
    <high>
221
      <repeatable>true</repeatable>
222
      <binding>
223
        <command>nasal</command>
224
        <script>chinese_hat(0, -1)</script>
225
      </binding>
226
    </high>
227
  </axis>
228

            
229
  <button n="1">
230
    <desc>Swap first and second views</desc>
231
    <binding>
232
      <command>nasal</command>
233
      <script>joystick_button[2](1)</script>
234
    </binding>
235
    <mod-up>
236
      <binding>
237
        <command>nasal</command>
238
        <script>joystick_button[2](0)</script>
239
      </binding>
240
    </mod-up>
241
  </button>
242

            
243
  <button n="2">
244
    <desc>Apply brakes</desc>
245
    <binding>
246
      <command>nasal</command>
247
      <script>joystick_button[3](0)</script>
248
    </binding>
249
    <mod-up>
250
      <binding>
251
        <command>nasal</command>
252
        <script>joystick_button[3](1)</script>
253
      </binding>
254
    </mod-up>
255
  </button>
256

            
257
  <button n="4">
258
    <desc>Extend Flaps Incrementally</desc>
259
    <repeatable>false</repeatable>
260
    <binding>
261
      <command>nasal</command>
262
      <script>joystick_button[5]()</script>
263
    </binding>
264
  </button>
265

            
266
  <button n="5">
267
    <desc>Retract Flaps Incrementally</desc>
268
    <repeatable>false</repeatable>
269
    <binding>
270
      <command>nasal</command>
271
      <script>joystick_button[6]()</script>
272
    </binding>
273
  </button>
274

            
275
  <button n="6">
276
    <desc>Handle mixture | add or remove engine 0</desc>
277
    <repeatable>true</repeatable>
278
    <binding>
279
      <command>nasal</command>
280
      <script>joystick_button[7]()</script>
281
    </binding>
282
  </button>
283

            
284
  <button n="7">
285
    <desc>Handle mixture | add or remove engine 1</desc>
286
    <repeatable>true</repeatable>
287
    <binding>
288
      <command>nasal</command>
289
      <script>joystick_button[8]()</script>
290
    </binding>
291
  </button>
292

            
293
  <button n="8">
294
    <desc>Handle mixture | add or remove engine 2</desc>
295
    <repeatable>true</repeatable>
296
    <binding>
297
      <command>nasal</command>
298
      <script>joystick_button[9]()</script>
299
    </binding>
300
  </button>
301

            
302
  <button n="9">
303
    <desc>Handle mixture | add or remove engine 3</desc>
304
    <repeatable>true</repeatable>
305
    <binding>
306
      <command>nasal</command>
307
      <script>joystick_button[10]()</script>
308
    </binding>
309
  </button>
310

            
311
</PropertyList>
312

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