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

            
96
        4 : func {
97
        },
98

            
99
        5 : func {
100
          controls.flapsDown(1)
101
        },
102

            
103
        6 : func {
104
          if    (getprop(pressed_button[10])) {
105
            for (var i = 0; i < 4; i += 1)
106
              controls.engines[i].selected.setBoolValue(1);
107
            printf("all engines added to joystick controls");
108
            gui.popupTip("joystick controls all engines");
109
          }
110
          elsif (getprop(pressed_button[11])) {
111
            for (var i = 0; i < 4; i += 1)
112
              controls.engines[i].selected.setBoolValue(0);
113
            printf("joystick controls no engines", i);
114
            gui.popupTip("joystick controls no engine");
115
          }
116
          else
117
            controls.flapsDown(-1)
118
        },
119

            
120
        7 : func {
121
          if    (getprop(pressed_button[10])) addSelectedEngine(2);
122
          elsif (getprop(pressed_button[11])) removeSelectedEngine(2);
123
          else controls.adjMixture(1);
124
        },
125

            
126
        8 : func {
127
          if    (getprop(pressed_button[10])) addSelectedEngine(3);
128
          elsif (getprop(pressed_button[11])) removeSelectedEngine(3);
129
          else controls.adjMixture(-1);
130
        },
131

            
132
        9 : func {
133
          if    (getprop(pressed_button[10])) addSelectedEngine(1);
134
          elsif (getprop(pressed_button[11])) removeSelectedEngine(1);
135
          else controls.adjPropeller(1);
136
        },
137

            
138
        10 : func {
139
          if    (getprop(pressed_button[10])) addSelectedEngine(0);
140
          elsif (getprop(pressed_button[11])) removeSelectedEngine(0);
141
          else controls.adjPropeller(-1);
142
        },
143
      }
144
    ]]></script>
145
  </nasal>
146

            
147
  <name type="string">T.Flight Stick X</name>
148
  <name type="string">Thrustmaster T.Flight Stick X</name>
149

            
150
  <axis n="0">
151
    <desc>Aileron</desc>
152
    <binding>
153
      <command>property-scale</command>
154
      <property>/controls/flight/aileron</property>
155
      <squared type="bool">true</squared>
156
    </binding>
157
  </axis>
158

            
159
  <axis n="1">
160
    <desc>Elevator</desc>
161
    <binding>
162
      <command>property-scale</command>
163
      <property>/controls/flight/elevator</property>
164
      <factor type="double">-1.0</factor>
165
      <squared type="bool">true</squared>
166
    </binding>
167
  </axis>
168

            
169
  <axis>
170
    <number>
171
      <windows>2</windows>
172
      <unix>3</unix>
173
    </number>
174
    <desc>Increase/Reduce Throttle</desc>
175
    <binding>
176
      <command>nasal</command>
177
      <script>controls.throttleAxis()</script>
178
    </binding>
179
  </axis>
180

            
181
  <axis>
182
    <number>
183
      <windows>3</windows>
184
      <unix>2</unix>
185
    </number>
186
    <desc>Rudder Left/Right</desc>
187
    <binding>
188
      <command>property-scale</command>
189
      <property>/controls/flight/rudder</property>
190
      <factor type="double">1.0</factor>
191
    </binding>
192
  </axis>
193

            
194
  <axis>
195
    <number>
196
      <windows>6</windows>
197
      <unix>4</unix>
198
    </number>
199
    <desc>View Direction | reset FoV | reset view direction</desc>
200
    <low>
201
      <repeatable>true</repeatable>
202
      <binding>
203
        <command>nasal</command>
204
        <script>chinese_hat(1, 0)</script>
205
      </binding>
206
    </low>
207
    <high>
208
      <repeatable>true</repeatable>
209
      <binding>
210
        <command>nasal</command>
211
        <script>chinese_hat(-1, 0)</script>
212
      </binding>
213
    </high>
214
  </axis>
215

            
216
  <axis>
217
    <number>
218
      <windows>7</windows>
219
      <unix>5</unix>
220
    </number>
221
    <desc>Orientation up or down / Increase or decrease FoV</desc>
222
    <low>
223
      <repeatable>true</repeatable>
224
      <binding>
225
        <command>nasal</command>
226
        <script>chinese_hat(0, 1)</script>
227
      </binding>
228
    </low>
229
    <high>
230
      <repeatable>true</repeatable>
231
      <binding>
232
        <command>nasal</command>
233
        <script>chinese_hat(0, -1)</script>
234
      </binding>
235
    </high>
236
  </axis>
237

            
238
  <button n="1">
239
    <desc>Swap first and second views</desc>
240
    <binding>
241
      <command>nasal</command>
242
      <script>joystick_button[2](1)</script>
243
    </binding>
244
    <mod-up>
245
      <binding>
246
        <command>nasal</command>
247
        <script>joystick_button[2](0)</script>
248
      </binding>
249
    </mod-up>
250
  </button>
251

            
252
  <button n="2">
253
    <desc>Apply brakes</desc>
254
    <binding>
255
      <command>nasal</command>
256
      <script>joystick_button[3](0)</script>
257
    </binding>
258
    <mod-up>
259
      <binding>
260
        <command>nasal</command>
261
        <script>joystick_button[3](1)</script>
262
      </binding>
263
    </mod-up>
264
  </button>
265

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

            
275
  <button n="5">
276
    <desc>Retract Flaps Incrementally</desc>
277
    <repeatable>false</repeatable>
278
    <binding>
279
      <command>nasal</command>
280
      <script>joystick_button[6]()</script>
281
    </binding>
282
  </button>
283

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

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

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

            
311
  <button n="9">
312
    <desc>Handle mixture | add or remove engine 3</desc>
313
    <repeatable>true</repeatable>
314
    <binding>
315
      <command>nasal</command>
316
      <script>joystick_button[10]()</script>
317
    </binding>
318
  </button>
319

            
320
</PropertyList>
321

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