--- To download a copy of this file, click here: ./X52.xml ---

--- A patch against the recent CVS version may be here: ./X52.xml.diff ---


<?xml version="1.0"?>
<!--

This is X52.xml, the joystick config file for the Saitek X52 
USB stick and throttle.

For details on what this does and why, see the Docs/README.X52 file.

-->

<PropertyList>
 <name>Saitek X52</name>
 <name>Saitek Saitek X52</name>
 <name>Saitek X52 Flight Controller USB</name>
 <name>Saitek X52 Flight Controller</name>
 <name>Saitek X52 Flight Control Stick </name>
 <name>Saitek Saitek X52 Flight Control Stick </name>
 <name>Saitek X52 Flight Stick (USB)</name>
 <name>Saitek Saitek X52 Flight Stick (USB)</name>
 <name>Saitek Saitek X52 Flight Control System</name>

<axis>	<!-- 0/0/0 -->
  <desc>Aileron</desc>
  <number>
   <unix>0</unix>
   <mac>0</mac>
   <windows>0</windows>
  </number>
  <binding>
   <command>property-scale</command>
   <property>/controls/flight/aileron</property>
  </binding>
</axis>

<axis>  <!-- 1/1/1 -->
  <desc>Elevator</desc>
  <number>
   <unix>1</unix>
   <mac>1</mac>
   <windows>1</windows>
  </number>
  <binding>
   <command>property-scale</command>
   <property>/controls/flight/elevator</property>
   <factor type="double">-1.0</factor>
  </binding>
</axis>

<axis>  <!-- 2/2/2 -->
  <desc>Throttle</desc>
  <number>
   <unix>2</unix>
   <mac>2</mac>
   <windows>2</windows>
  </number>
  <binding>
   <command>nasal</command>
   <script>controls.throttleAxis()</script>
  </binding>
</axis>

<axis>  <!-- 3/5/5 -->
  <desc>Mixture</desc>
  <number>
   <unix>3</unix>
   <mac>5</mac>
   <windows>5</windows>
  </number>
  <binding>
   <command>nasal</command>
   <script>controls.mixtureAxis(-1)</script>
  </binding>
</axis>

<!-- Alternate Prop RPM :: throttle upper rotary -->
<axis>  <!-- 4/8/8 -->
  <desc>unassigned (was: Propeller RPM)</desc>
  <number>
   <unix>4</unix>
   <mac>8</mac>
   <windows>8</windows>
  </number>
  <binding>
   <command>nasal</command>
   <script>
     ####controls.propellerAxis(-1)
   </script>
  </binding>
</axis>

<!-- Rudder :: stick twist -->
<axis>  <!-- 5/3/3 -->
    <desc>Rudder</desc>
    <number>
	<unix>5</unix>
	<mac>3</mac>
	<windows>3</windows>
    </number>
    <binding>
	<command>property-scale</command>
	<property>/controls/flight/rudder</property>
    </binding>
</axis>

<!-- Propeller RPM :: throttle thumb slider --> 
<axis>  <!-- 6/4/4 -->
  <desc>Propeller RPM</desc>
  <number>
   <unix>6</unix>
   <mac>4</mac>
   <windows>4</windows>
  </number>
  <binding>
   <command>nasal</command>
   <script>controls.propellerAxis(-1)</script>
  </binding>
</axis>


<!-- View Direction :: stick lower hat -->
<axis>  <!-- 7/6/6 -->
  <desc>View Pan Left/Right (D-shift: move PoV)</desc>
  <number>
   <unix>7</unix>
   <mac>6</mac>
   <windows>6</windows>
  </number>
  <low>
   <repeatable>true</repeatable>
   <binding>
    <command>nasal</command>
    <script>
      if (getprop("/sim/gui/d-button")){
        setprop("/sim/current-view/x-offset-m", 
	  -0.01 + getprop("/sim/current-view/x-offset-m"));
      } else {
	view.panViewDir(1)
      }
    </script>
   </binding>
  </low>
  <high>
   <repeatable>true</repeatable>
   <binding>
    <command>nasal</command>
    <script>
      if (getprop("/sim/gui/d-button")){
        setprop("/sim/current-view/x-offset-m", 
	  0.01 + getprop("/sim/current-view/x-offset-m"));
      } else {
	view.panViewDir(-1)
      }
    </script>
   </binding>
  </high>
</axis>

<axis> <!-- 8/7/7 -->
  <desc>View Tilt Up/Down (D-shift: move PoV)</desc>
  <number>
   <unix>8</unix>
   <mac>7</mac>
   <windows>7</windows>
  </number>
  <low>
   <repeatable>true</repeatable>
   <binding>
    <command>nasal</command>
    <script>
      if (getprop("/sim/gui/d-button")){
        setprop("/sim/current-view/y-offset-m", 
	  0.01 + getprop("/sim/current-view/y-offset-m"));
      } else {
        view.panViewPitch(1)
      }
    </script>
   </binding>
  </low>
  <high>
   <repeatable>true</repeatable>
   <binding>
    <command>nasal</command>
    <script>
      if (getprop("/sim/gui/d-button")){
        setprop("/sim/current-view/y-offset-m", 
	  -0.01 + getprop("/sim/current-view/y-offset-m"));
      } else {
        view.panViewPitch(-1)
      }
    </script>
   </binding>
  </high>
</axis>


<!-- End of axes;  now on to buttons -->

<button n="1">
   <desc>(FIRE) : Auto-Coordination off (D-shift: on)</desc>
   <binding>
    <command>nasal</command>
    <script>
      setprop("/sim/auto-coordination", ! !getprop("/sim/gui/d-button"));
    </script>
   </binding>
</button>


<button n="3">
   <desc>(B) : Zoom out i.e. increase field of view (D-shift: zoom in)</desc>
   <repeatable type="bool">true</repeatable>
   <binding>
    <command>nasal</command>
    <script>
      if ( getprop("/sim/gui/d-button") ) {
        view.decrease(0.5)		# zoom in
      } else {
        view.increase(0.5)		# zoom out
      }
    </script>
   </binding>
</button>

<button n="4">
  <desc>(C) : Reset View</desc>
  <binding>
   <command>nasal</command>
   <script>
     view.resetView();		# only resets tilt/pan/zoom:
				# must reset x/y/z view point separately
     vn = getprop("/sim/current-view/view-number");
     conf = sprintf("/sim/view[%d]/config", vn);
     foreach (parm ; ["x-offset-m", "y-offset-m", "z-offset-m"]) {
       setprop("/sim/current-view/", parm, getprop(conf, parm));
     }
   </script>
  </binding>
</button>

<!-- Main brakes (not parking brakes) :: pinky subtrigger -->
<button n="5">
  <desc>(Pinky) : Brakes</desc>
  <binding>
   <command>nasal</command>
   <script>controls.applyBrakes(1)</script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>controls.applyBrakes(0)</script>
   </binding>
  </mod-up>
</button>

<!-- Shift :: (D) button -->
<button n="6">
  <desc>(D) : Shift Key</desc>
  <binding>
   <command>nasal</command>
   <script>
     setprop("/sim/gui/d-button", 1);
   </script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>
      setprop("/sim/gui/d-button", 0);
    </script>
   </binding>
  </mod-up>
</button>


  <!-- gear handle up/down :: button T1/T2 -->
  <button n="8">
   <desc>(T1) : Landing Gear Handle Up</desc>
    <binding>
     <command>nasal</command>
      <script>
       controls.gearDown(-1)
     </script>
    </binding>
  </button>
  <button n="9">
    <desc>(T2) : Landing Gear Handle Down</desc>
    <binding>
     <command>nasal</command>
     <script>
       controls.gearDown(1)
     </script>
    </binding>
  </button>


<!-- Pitch trim :: stick upper hat Up/Dn -->
<button n="15">
  <desc>Elevator trim down</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.elevatorTrim(0.6)</script>
  </binding>
</button>
<button n="17">
  <desc>Elevator trim up</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.elevatorTrim(-0.6)</script>
  </binding>
</button>

<!-- Rudder trim :: stick upper hat L/R -->
<button n="16">
  <desc>(Throttle Rocker) : Rudder trim right</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.rudderTrim(1)</script>
  </binding>
</button>
<button n="18">
  <desc>(Throttle Rocker) : Rudder trim left</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.rudderTrim(-1)</script>
  </binding>
</button>

<!-- Flaps (shift: Speed Brakes) :: T3/T4 -->
<button n="10">
  <desc>(T3) : Decrease flaps (shift: Speed Brakes extend)</desc>
  <binding>
   <command>nasal</command>
   <script>
     if ( getprop("/sim/gui/d-button") ) {
       setprop("/controls/flight/speedbrake", 1);
     } else {
       controls.flapsDown(-1)
     }
   </script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>
      if ( getprop("/sim/gui/d-button") ) {
        
      } else {
	controls.flapsDown(0)
      }
    </script>
   </binding>
  </mod-up>
</button>
<button n="11">
  <desc>(T4) : Increase flaps (shift: Speed Brakes retract)</desc>
  <binding>
   <command>nasal</command>
   <script>
     if ( getprop("/sim/gui/d-button") ) {
       setprop("/controls/flight/speedbrake", 0);
     } else {
       controls.flapsDown(1)
     }
   </script>
  </binding>
  <mod-up>
   <binding>
    <command>nasal</command>
    <script>
      if ( getprop("/sim/gui/d-button") ) {
        
      } else {
	controls.flapsDown(0)
      }
    </script>
   </binding>
  </mod-up>
</button>

  <!-- Carb Heat (shift: Cowl Flaps) :: T6/T5 -->
  <button n="12">
    <desc>(T5) : Carb Heat On (shift: Cowl Flaps Close)</desc>
    <binding>
     <command>nasal</command>
     <script>
       if ( getprop("/sim/gui/d-button") ) {
         props.setAll("/controls/engines/engine", "cowl-flaps-norm", 1);
       } else {
         props.setAll("/controls/engines/engine", "carb-heat", 0);
       }
     </script>
    </binding>
  </button>
  <button n="13">
    <desc>(T6) : Carb Heat Off (shift: Cowl Flaps Open)</desc>
    <binding>
     <command>nasal</command>
     <script>
       if ( getprop("/sim/gui/d-button") ) {
         props.setAll("/controls/engines/engine", "cowl-flaps-norm", 0);
       } else {
         props.setAll("/controls/engines/engine", "carb-heat", 1);
       }
     </script>
    </binding>
  </button>

<!-- Rudder trim :: throttle rocker -->
<button n="20">
  <desc>Aileron trim right</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.aileronTrim(0.5)</script>
  </binding>
</button>
<button n="22">
  <desc>Aileron trim left</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.aileronTrim(-0.5)</script>
  </binding>
</button>

<!-- What does this do ???? -->
<!-- mode switch (buttons 23-25) -->
<button n="23">
  <desc>Mode 1</desc>
  <binding>
   <command>nasal</command>
   <script>setprop("/input/joysticks/js[0]/saitek-x52-mode",
1)</script>
  </binding>
</button>
<button n="24">
  <desc>Mode 2</desc>
  <binding>
   <command>nasal</command>
   <script>setprop("/input/joysticks/js[0]/saitek-x52-mode",
2)</script>
  </binding>
</button>
<button n="25">
  <desc>Mode 3</desc>
  <binding>
   <command>nasal</command>
   <script>setprop("/input/joysticks/js[0]/saitek-x52-mode",
3)</script>
  </binding>
</button>

<button n="26">
  <desc>(MFD Func) : Stopwatch timer becomes clock again</desc>
  <binding>
   <command>nasal</command>
   <script>
      props.globals.getNode("/instrumentation/clock/offset-sec", 1).setValue(0);
   </script>
  </binding>
</button>

<button n="28">
  <desc>(MFD Reset) : Stopwatch timer reset</desc>
  <binding>
   <command>nasal</command>
   <script>
   <!-- Note that the "indicated-sec" variable is a large number,
     probably seconds since midnight ... *not* modulo 60. -->
      ttt = props.globals.getNode("/instrumentation/clock/indicated-sec", 1).getValue();
      node = props.globals.getNode("/instrumentation/clock/offset-sec", 1);
      off = node.getValue();
      node.setValue(off-ttt);
   </script>
  </binding>
</button>

<!-- (i) button -->
<button n="29">
  <desc>(i) : Dump Information to Console</desc>
  <binding>
   <command>nasal</command>
   <script>
      props.dump(props.globals);
      #props.dump(props.globals.getNode("/engines", 1));
      #props.dump(props.globals.getNode("/instrumentation", 1));
      #props.dump(props.globals.getNode("/sim", 1));
      #props.dump(props.globals.getNode("/controls", 1));
      #props.dump(props.globals.getNode("/sim/presets", 1));
      #props.dump(props.globals.getNode("/gear"));

   </script>
  </binding>
</button>

<!-- Parking brake :: unbound -->
<button n="666">
   <desc>Toggle parking brake on or off</desc>
   <binding>
     <command>property-toggle</command>
     <property>/controls/gear/brake-parking</property>
   </binding>
</button>

</PropertyList>