| 1 |
<?xml version="1.0"?> |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
<PropertyList> |
| 9 |
<name>Thrustmaster Throttle - HOTAS Warthog</name> |
| 10 |
<name>Throttle - HOTAS Warthog</name> |
| 11 |
|
| 12 |
<nasal> |
| 13 |
<script> |
| 14 |
var this = cmdarg().getParent(); |
| 15 |
var init = !contains(caller(0)[0], "init"); |
| 16 |
if (!contains(globals, "warthog")) |
| 17 |
io.load_nasal(getprop("/sim/fg-root") ~ "/Input/Joysticks/ThrustMaster/Warthog/warthog.nas"); |
| 18 |
|
| 19 |
var jslistener = func init and call(setlistener, arg); |
| 20 |
var popup = func gui.popupTip(call(sprintf, arg)); |
| 21 |
var is_helicopter = (func {(var n = props.globals.getNode("rotors", 0)) != nil and n.getAttribute("children")})(); |
| 22 |
var aircraft_type = getprop("/sim/type"); |
| 23 |
|
| 24 |
var load_overlay = func(name) { |
| 25 |
foreach (var dir; [getprop("/sim/fg-home"), getprop("/sim/fg-root")]) { |
| 26 |
var file = dir ~ "/Input/Joysticks/ThrustMaster/Warthog/Throttle/" ~ name ~ ".xml"; |
| 27 |
if (io.stat(file) != nil) { |
| 28 |
printlog("info", "WARTHOG: loading overlay " ~ file); |
| 29 |
cmdarg().setValues({command: "nasal", script: ""}); |
| 30 |
io.read_properties(file, this); |
| 31 |
props.runBinding(cmdarg()); |
| 32 |
break; |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
foreach (var b; this.getChildren("button")) { |
| 38 |
if (b.getAttribute("children") == 1) { |
| 39 |
var name = b.getNode("name", 1).getValue() or "??"; |
| 40 |
b.setValues({binding: {command: "nasal", script: 'popup("' ~ name ~ '")'}}); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
var gearcheck = func { |
| 45 |
var agl = getprop("/position/altitude-agl-ft"); |
| 46 |
var geardown = getprop("/controls/gear/gear-down"); |
| 47 |
if (agl < 500 and !geardown) |
| 48 |
warthog.throttle.toggle_leds(1, 2, 3, 4, 5); |
| 49 |
else |
| 50 |
warthog.throttle.set_leds(0, 1, 2, 3, 4, 5); |
| 51 |
settimer(gearcheck, 0.5); |
| 52 |
}; |
| 53 |
if (init) |
| 54 |
gearcheck(); |
| 55 |
|
| 56 |
var mod = 0; |
| 57 |
var m = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT"); |
| 58 |
jslistener(m, func(n) mod = n.getValue()); |
| 59 |
|
| 60 |
var left_engines = [0, 2, 4, 6, 8, 10]; |
| 61 |
var right_engines = [1, 3, 5, 7, 9, 11]; |
| 62 |
|
| 63 |
load_overlay("generic"); |
| 64 |
if (is_helicopter) |
| 65 |
load_overlay("helicopter"); |
| 66 |
if (aircraft_type) |
| 67 |
load_overlay(aircraft_type); |
| 68 |
foreach (var o; split(":", getprop("/input/joysticks/overlays") or "")) |
| 69 |
load_overlay(o); |
| 70 |
load_overlay(getprop("/sim/aircraft")); |
| 71 |
</script> |
| 72 |
</nasal> |
| 73 |
|
| 74 |
<axis n="0"> |
| 75 |
<name>Mouse Horizontal</name> |
| 76 |
</axis> |
| 77 |
|
| 78 |
<axis n="1"> |
| 79 |
<name>Mouse Vertical</name> |
| 80 |
</axis> |
| 81 |
|
| 82 |
<axis n="2"> |
| 83 |
<name>Right Throttle</name> |
| 84 |
<desc>right throttle</desc> |
| 85 |
<tolerance>0.00001</tolerance> |
| 86 |
<binding> |
| 87 |
<command>nasal</command> |
| 88 |
<script>controls.perEngineSelectedAxisHandler(0)(right_engines)</script> |
| 89 |
</binding> |
| 90 |
</axis> |
| 91 |
|
| 92 |
<axis n="3"> |
| 93 |
<name>Left Throttle</name> |
| 94 |
<desc>left throttle</desc> |
| 95 |
<number> |
| 96 |
<unix>3</unix> |
| 97 |
<mac>3</mac> |
| 98 |
<windows>5</windows> |
| 99 |
</number> |
| 100 |
<tolerance>0.00001</tolerance> |
| 101 |
<binding> |
| 102 |
<command>nasal</command> |
| 103 |
<script>controls.perEngineSelectedAxisHandler(0)(left_engines)</script> |
| 104 |
</binding> |
| 105 |
</axis> |
| 106 |
|
| 107 |
<axis n="4"> |
| 108 |
<name>Friction Wheel</name> |
| 109 |
<desc>rudder trim</desc> |
| 110 |
<number> |
| 111 |
<unix>4</unix> |
| 112 |
<mac>4</mac> |
| 113 |
<windows>6</windows> |
| 114 |
</number> |
| 115 |
<binding> |
| 116 |
<command>property-scale</command> |
| 117 |
<property>/controls/flight/rudder-trim</property> |
| 118 |
<factor type="double">-1</factor> |
| 119 |
<power type="int">2</power> |
| 120 |
</binding> |
| 121 |
</axis> |
| 122 |
|
| 123 |
<axis n="5"> |
| 124 |
<name>Hat Switch Horizontal</name> |
| 125 |
<desc>adjust mixture: left = leaner, right = fatter</desc> |
| 126 |
<number> |
| 127 |
<unix>5</unix> |
| 128 |
<mac>5</mac> |
| 129 |
<windows>3</windows> |
| 130 |
</number> |
| 131 |
<low> |
| 132 |
<repeatable>true</repeatable> |
| 133 |
<binding> |
| 134 |
<command>nasal</command> |
| 135 |
<script>controls.adjMixture(-1)</script> |
| 136 |
</binding> |
| 137 |
</low> |
| 138 |
<high> |
| 139 |
<repeatable>true</repeatable> |
| 140 |
<binding> |
| 141 |
<command>nasal</command> |
| 142 |
<script>controls.adjMixture(1)</script> |
| 143 |
</binding> |
| 144 |
</high> |
| 145 |
</axis> |
| 146 |
|
| 147 |
<axis n="6"> |
| 148 |
<name>Hat Switch Vertical</name> |
| 149 |
<desc>adjust propeller pitch: forward = increase, backward = decrease</desc> |
| 150 |
<number> |
| 151 |
<unix>6</unix> |
| 152 |
<mac>6</mac> |
| 153 |
<windows>4</windows> |
| 154 |
</number> |
| 155 |
<low> |
| 156 |
<repeatable>true</repeatable> |
| 157 |
<binding> |
| 158 |
<command>nasal</command> |
| 159 |
<script>controls.adjPropeller(1)</script> |
| 160 |
</binding> |
| 161 |
</low> |
| 162 |
<high> |
| 163 |
<repeatable>true</repeatable> |
| 164 |
<binding> |
| 165 |
<command>nasal</command> |
| 166 |
<script>controls.adjPropeller(-1)</script> |
| 167 |
</binding> |
| 168 |
</high> |
| 169 |
</axis> |
| 170 |
|
| 171 |
<button n="0"> |
| 172 |
<name>Mouse Button</name> |
| 173 |
</button> |
| 174 |
|
| 175 |
<button n="1"> |
| 176 |
<name>MIC Switch Push</name> |
| 177 |
<desc>Push To Talk (PTT)</desc> |
| 178 |
<binding> |
| 179 |
<command>nasal</command> |
| 180 |
<script>controls.ptt(1)</script> |
| 181 |
</binding> |
| 182 |
<mod-up> |
| 183 |
<binding> |
| 184 |
<command>nasal</command> |
| 185 |
<script>controls.ptt(0)</script> |
| 186 |
</binding> |
| 187 |
</mod-up> |
| 188 |
</button> |
| 189 |
|
| 190 |
<button n="2"> |
| 191 |
<name>MIC Switch Up</name> |
| 192 |
</button> |
| 193 |
|
| 194 |
<button n="3"> |
| 195 |
<name>MIC Switch Forward</name> |
| 196 |
</button> |
| 197 |
|
| 198 |
<button n="4"> |
| 199 |
<name>MIC Switch Down</name> |
| 200 |
</button> |
| 201 |
|
| 202 |
<button n="5"> |
| 203 |
<name>MIC Switch Aft</name> |
| 204 |
</button> |
| 205 |
|
| 206 |
<button n="6"> |
| 207 |
<name>Speedbrake Forward (right throttle, top grey)</name> |
| 208 |
<desc>apply speed brake</desc> |
| 209 |
<binding> |
| 210 |
<command>property-assign</command> |
| 211 |
<property>/controls/flight/speedbrake</property> |
| 212 |
<value>1</value> |
| 213 |
</binding> |
| 214 |
<mod-up> |
| 215 |
<binding> |
| 216 |
<command>property-assign</command> |
| 217 |
<property>/controls/flight/speedbrake</property> |
| 218 |
<value>0</value> |
| 219 |
</binding> |
| 220 |
</mod-up> |
| 221 |
</button> |
| 222 |
|
| 223 |
<button n="7"> |
| 224 |
<name>Speedbrake Aft</name> |
| 225 |
</button> |
| 226 |
|
| 227 |
<button n="8"> |
| 228 |
<name>Boat Switch Forward</name> |
| 229 |
</button> |
| 230 |
|
| 231 |
<button n="9"> |
| 232 |
<name>Boat Switch Aft</name> |
| 233 |
<desc>apply thrust reverser</desc> |
| 234 |
<binding> |
| 235 |
<command>nasal</command> |
| 236 |
<script>props.setAll("/controls/engines/engine", "reverser", 1)</script> |
| 237 |
</binding> |
| 238 |
<mod-up> |
| 239 |
<binding> |
| 240 |
<command>nasal</command> |
| 241 |
<script>props.setAll("/controls/engines/engine", "reverser", 0)</script> |
| 242 |
</binding> |
| 243 |
</mod-up> |
| 244 |
</button> |
| 245 |
|
| 246 |
<button n="10"> |
| 247 |
<name>China Hat Forward</name> |
| 248 |
<desc>+mod: increase LED brightness (see README)</desc> |
| 249 |
<binding> |
| 250 |
<command>nasal</command> |
| 251 |
<script> |
| 252 |
if (mod) |
| 253 |
warthog.throttle.brighter(); |
| 254 |
</script> |
| 255 |
</binding> |
| 256 |
</button> |
| 257 |
|
| 258 |
<button n="11"> |
| 259 |
<name>China Hat Aft</name> |
| 260 |
<desc>+mod: decrease LED brightness (see README)</desc> |
| 261 |
<binding> |
| 262 |
<command>nasal</command> |
| 263 |
<script> |
| 264 |
if (mod) |
| 265 |
warthog.throttle.darker(); |
| 266 |
</script> |
| 267 |
</binding> |
| 268 |
</button> |
| 269 |
|
| 270 |
<button n="12"> |
| 271 |
<name>Pinky Switch Forward</name> |
| 272 |
</button> |
| 273 |
|
| 274 |
<button n="13"> |
| 275 |
<name>Pinky Switch Aft</name> |
| 276 |
</button> |
| 277 |
|
| 278 |
<button n="14"> |
| 279 |
<name>Left Throttle Button</name> |
| 280 |
</button> |
| 281 |
|
| 282 |
<button n="15"> |
| 283 |
<name>Engine Fuel Flow Left</name> |
| 284 |
<desc>engine fuel flow left</desc> |
| 285 |
<binding> |
| 286 |
<command>nasal</command> |
| 287 |
<script> |
| 288 |
foreach (var i; left_engines) |
| 289 |
setprop("/controls/engines/engine[" ~ i ~ "]/fuel-pump", 1); |
| 290 |
</script> |
| 291 |
</binding> |
| 292 |
<mod-up> |
| 293 |
<binding> |
| 294 |
<command>nasal</command> |
| 295 |
<script> |
| 296 |
foreach (var i; left_engines) |
| 297 |
setprop("/controls/engines/engine[" ~ i ~ "]/fuel-pump", 0); |
| 298 |
</script> |
| 299 |
</binding> |
| 300 |
</mod-up> |
| 301 |
</button> |
| 302 |
|
| 303 |
<button n="16"> |
| 304 |
<name>Engine Fuel Flow Right</name> |
| 305 |
<desc>engine fuel flow right</desc> |
| 306 |
<binding> |
| 307 |
<command>nasal</command> |
| 308 |
<script> |
| 309 |
foreach (var i; right_engines) |
| 310 |
setprop("/controls/engines/engine[" ~ i ~ "]/fuel-pump", 1); |
| 311 |
</script> |
| 312 |
</binding> |
| 313 |
<mod-up> |
| 314 |
<binding> |
| 315 |
<command>nasal</command> |
| 316 |
<script> |
| 317 |
foreach (var i; right_engines) |
| 318 |
setprop("/controls/engines/engine[" ~ i ~ "]/fuel-pump", 0); |
| 319 |
</script> |
| 320 |
</binding> |
| 321 |
</mod-up> |
| 322 |
</button> |
| 323 |
|
| 324 |
<button n="17"> |
| 325 |
<name>Engine Operate Left MOTOR</name> |
| 326 |
<desc>engine operate left motor (magnetos)</desc> |
| 327 |
<binding> |
| 328 |
<command>nasal</command> |
| 329 |
<script> |
| 330 |
foreach (var i; left_engines) |
| 331 |
setprop("/controls/engines/engine[" ~ i ~ "]/magnetos", 1); |
| 332 |
</script> |
| 333 |
</binding> |
| 334 |
<mod-up> |
| 335 |
<binding> |
| 336 |
<command>nasal</command> |
| 337 |
<script> |
| 338 |
foreach (var i; left_engines) |
| 339 |
setprop("/controls/engines/engine[" ~ i ~ "]/magnetos", 0); |
| 340 |
</script> |
| 341 |
</binding> |
| 342 |
</mod-up> |
| 343 |
</button> |
| 344 |
|
| 345 |
<button n="18"> |
| 346 |
<name>Engine Operate Right MOTOR</name> |
| 347 |
<desc>engine operate right motor (magnetos)</desc> |
| 348 |
<binding> |
| 349 |
<command>nasal</command> |
| 350 |
<script> |
| 351 |
foreach (var i; right_engines) |
| 352 |
setprop("/controls/engines/engine[" ~ i ~ "]/magnetos", 1); |
| 353 |
</script> |
| 354 |
</binding> |
| 355 |
<mod-up> |
| 356 |
<binding> |
| 357 |
<command>nasal</command> |
| 358 |
<script> |
| 359 |
foreach (var i; right_engines) |
| 360 |
setprop("/controls/engines/engine[" ~ i ~ "]/magnetos", 0); |
| 361 |
</script> |
| 362 |
</binding> |
| 363 |
</mod-up> |
| 364 |
</button> |
| 365 |
|
| 366 |
<button n="19"> |
| 367 |
<name>APU Start</name> |
| 368 |
<desc>APU (auxiliary power unit) on/off</desc> |
| 369 |
<binding> |
| 370 |
<command>property-assign</command> |
| 371 |
<property>/controls/electric/APU-generator</property> |
| 372 |
<value>1</value> |
| 373 |
</binding> |
| 374 |
<mod-up> |
| 375 |
<binding> |
| 376 |
<command>property-assign</command> |
| 377 |
<property>/controls/electric/APU-generator</property> |
| 378 |
<value>0</value> |
| 379 |
</binding> |
| 380 |
</mod-up> |
| 381 |
</button> |
| 382 |
|
| 383 |
<button n="20"> |
| 384 |
<name>Landing Gear Horn Silence</name> |
| 385 |
<desc>gear up, +mod: gear down</desc> |
| 386 |
<binding> |
| 387 |
<command>nasal</command> |
| 388 |
<script>controls.gearDown(mod ? 1 : -1)</script> |
| 389 |
</binding> |
| 390 |
<mod-up> |
| 391 |
<binding> |
| 392 |
<command>nasal</command> |
| 393 |
<script>controls.gearDown(0)</script> |
| 394 |
</binding> |
| 395 |
</mod-up> |
| 396 |
</button> |
| 397 |
|
| 398 |
<button n="21"> |
| 399 |
<name>Flaps Up</name> |
| 400 |
<desc>flaps up</desc> |
| 401 |
<binding> |
| 402 |
<command>nasal</command> |
| 403 |
<script>controls.flapsDown(-1)</script> |
| 404 |
</binding> |
| 405 |
<mod-up> |
| 406 |
<binding> |
| 407 |
<command>nasal</command> |
| 408 |
<script>controls.flapsDown(0)</script> |
| 409 |
</binding> |
| 410 |
</mod-up> |
| 411 |
</button> |
| 412 |
|
| 413 |
<button n="22"> |
| 414 |
<name>Flaps Down</name> |
| 415 |
<desc>flaps down</desc> |
| 416 |
<binding> |
| 417 |
<command>nasal</command> |
| 418 |
<script>controls.flapsDown(1)</script> |
| 419 |
</binding> |
| 420 |
<mod-up> |
| 421 |
<binding> |
| 422 |
<command>nasal</command> |
| 423 |
<script>controls.flapsDown(0)</script> |
| 424 |
</binding> |
| 425 |
</mod-up> |
| 426 |
</button> |
| 427 |
|
| 428 |
<button n="23"> |
| 429 |
<name>EAC Switch</name> |
| 430 |
</button> |
| 431 |
|
| 432 |
<button n="24"> |
| 433 |
<name>RADAR ALT</name> |
| 434 |
</button> |
| 435 |
|
| 436 |
<button n="25"> |
| 437 |
<name>Autopilot (Dis)Engage</name> |
| 438 |
</button> |
| 439 |
|
| 440 |
<button n="26"> |
| 441 |
<name>Autopilot PATH</name> |
| 442 |
<binding> |
| 443 |
<command>nasal</command> |
| 444 |
<script>popup("autopilot path")</script> |
| 445 |
</binding> |
| 446 |
<mod-up> |
| 447 |
<binding> |
| 448 |
<command>nasal</command> |
| 449 |
<script>popup("autopilot alt/hdg")</script> |
| 450 |
</binding> |
| 451 |
</mod-up> |
| 452 |
</button> |
| 453 |
|
| 454 |
<button n="27"> |
| 455 |
<name>Autopilot ALT</name> |
| 456 |
<binding> |
| 457 |
<command>nasal</command> |
| 458 |
<script>popup("autopilot alt")</script> |
| 459 |
</binding> |
| 460 |
<mod-up> |
| 461 |
<binding> |
| 462 |
<command>nasal</command> |
| 463 |
<script>popup("autopilot alt/hdg")</script> |
| 464 |
</binding> |
| 465 |
</mod-up> |
| 466 |
</button> |
| 467 |
|
| 468 |
<button n="28"> |
| 469 |
<name>Right Throttle Idle Switch</name> |
| 470 |
<desc>right engines cutoff</desc> |
| 471 |
<binding> |
| 472 |
<command>nasal</command> |
| 473 |
<script> |
| 474 |
foreach (var i; right_engines) |
| 475 |
setprop("/controls/engines/engine[" ~ i ~ "]/cutoff", 1); |
| 476 |
</script> |
| 477 |
</binding> |
| 478 |
<mod-up> |
| 479 |
<binding> |
| 480 |
<command>nasal</command> |
| 481 |
<script> |
| 482 |
foreach (var i; right_engines) |
| 483 |
setprop("/controls/engines/engine[" ~ i ~ "]/cutoff", 0); |
| 484 |
</script> |
| 485 |
</binding> |
| 486 |
</mod-up> |
| 487 |
</button> |
| 488 |
|
| 489 |
<button n="29"> |
| 490 |
<name>Left Throttle Idle Switch</name> |
| 491 |
<desc>left engines cutoff</desc> |
| 492 |
<binding> |
| 493 |
<command>nasal</command> |
| 494 |
<script> |
| 495 |
foreach (var i; left_engines) |
| 496 |
setprop("/controls/engines/engine[" ~ i ~ "]/cutoff", 1); |
| 497 |
</script> |
| 498 |
</binding> |
| 499 |
<mod-up> |
| 500 |
<binding> |
| 501 |
<command>nasal</command> |
| 502 |
<script> |
| 503 |
foreach (var i; left_engines) |
| 504 |
setprop("/controls/engines/engine[" ~ i ~ "]/cutoff", 0); |
| 505 |
</script> |
| 506 |
</binding> |
| 507 |
</mod-up> |
| 508 |
</button> |
| 509 |
|
| 510 |
<button n="30"> |
| 511 |
<name>Engine Operate Left IGN</name> |
| 512 |
<desc>start left engines</desc> |
| 513 |
<binding> |
| 514 |
<command>nasal</command> |
| 515 |
<script>call(controls.startEngine, [1] ~ left_engines)</script> |
| 516 |
</binding> |
| 517 |
<mod-up> |
| 518 |
<binding> |
| 519 |
<command>nasal</command> |
| 520 |
<script>call(controls.startEngine, [0] ~ left_engines)</script> |
| 521 |
</binding> |
| 522 |
</mod-up> |
| 523 |
</button> |
| 524 |
|
| 525 |
<button n="31"> |
| 526 |
<name>Engine Operate Right IGN</name> |
| 527 |
<desc>start right engines</desc> |
| 528 |
<binding> |
| 529 |
<command>nasal</command> |
| 530 |
<script>call(controls.startEngine, [1] ~ right_engines)</script> |
| 531 |
</binding> |
| 532 |
<mod-up> |
| 533 |
<binding> |
| 534 |
<command>nasal</command> |
| 535 |
<script>call(controls.startEngine, [0] ~ right_engines)</script> |
| 536 |
</binding> |
| 537 |
</mod-up> |
| 538 |
</button> |
| 539 |
</PropertyList> |