config / .fgfs / Input / Joysticks / Microsoft-SideWinder-Joystick.xml /
8bd07a2 4 years ago
2 contributor
301 lines | 7.97kb
<?xml version="1.0"?>

<!--
************************************************************************
* Bindings for Microsoft SideWinder Joystick.
*
*
* Axis 0: ailerons in air, rudder on ground if not heli
* Axis 1: elevator
* Axis 2: throttle
*
* Button 1: all brakes on ground, heli view in air
* Button 2: Push To Talk with FGCOM
* Button 3: left aileron trim for aircrafts, left pedal for helis
* Button 4: right aileron trim for aircrafts, right pedal for helis
* Button 5: elevator trim up
* Button 6: elevator trim down
* Button 7: flaps up
* Button 8: flaps down

************************************************************************
$Id: sidewinder.xml,v 1.5 2005/06/22 13:08:02 mfranz Exp $
modified by zakharov
-->

<PropertyList>
  <nasal>
    <script><![CDATA[
      var shift = props.globals.getNode("/devices/status/keyboard/shift");
      var ctrl = props.globals.getNode("/devices/status/keyboard/ctrl");
      var alt = props.globals.getNode("/devices/status/keyboard/alt");

      var get_modifiers = func {
          shift.getValue() + 2 * ctrl.getValue() + 4 * alt.getValue();
      }

      var space_release = func {}
      var space = func(state, mod) {
          if (!state) {
              space_release();
              return space_release = func {};
          }
          if (mod == 0 or mod == 1) {
              controls.ptt(mod + 1);
              space_release = func { controls.ptt(0) }
          }
      }

      var button0 = func {}
      var gunned = props.globals.getNode("/controls/armament/trigger");
      if (gunned != nil)
          button0 = func (v) { 
	      setprop("/ai/submodels/trigger", v);
	      setprop("/controls/armament/trigger", v);
	  }
      else
          button0 = func (v) { setprop("/sim/current-view/view-number", v); 
      }
    ]]></script>
  </nasal>

  <name>Microsoft SideWinder Joystick</name>

  <axis n="0">
    <desc>Rudder if not heli (auto-coordination), on ground and in air</desc>
    <binding>
      <condition>
        <not>
          <property>/rotors/rotor/brake</property>
        </not>
      </condition>
      <command>property-scale</command>
      <property>/controls/flight/rudder</property>
      <squared type="bool">true</squared>
    </binding>
    <desc>Aileron, only in air</desc>
    <binding>
      <condition>
        <not>
          <and>
            <property>/gear/gear[1]/wow</property>
            <property>/gear/gear[2]/wow</property>
          </and>
        </not>
      </condition>
      <command>property-scale</command>
      <property>/controls/flight/aileron</property>
      <squared type="bool">true</squared>
    </binding>
  </axis>

  <axis n="1">
    <desc>Elevator</desc>
    <binding>
      <command>property-scale</command>
      <property>/controls/flight/elevator</property>
      <factor type="double">-1.0</factor>
      <squared type="bool">true</squared>
    </binding>
  </axis>

  <axis n="2">
    <desc>Throttle</desc>
    <binding>
      <command>nasal</command>
      <script>controls.throttleAxis()</script>
    </binding>
  </axis>

  <button n="0">
    <desc>Brakes on ground, change view or fire gun if exists on air</desc>
    <binding>
      <condition>
        <and>
          <property>/gear/gear[1]/wow</property>
          <property>/gear/gear[2]/wow</property>
        </and>
      </condition>
      <command>nasal</command>
      <script>controls.applyBrakes(1)</script>
    </binding>
    <binding>
      <condition>
        <not>
          <and>
            <property>/gear/gear[1]/wow</property>
            <property>/gear/gear[2]/wow</property>
          </and>
        </not>
      </condition>
      <command>nasal</command>
      <script>button0(1)</script>
    </binding>
    <mod-up>
      <binding>
        <condition>
          <not>
            <and>
              <property>/gear/gear[1]/wow</property>
              <property>/gear/gear[2]/wow</property>
            </and>
          </not>
        </condition>
        <command>nasal</command>
        <script>button0(0)</script>
      </binding>
      <binding>
        <condition>
          <and>
            <property>/gear/gear[1]/wow</property>
            <property>/gear/gear[2]/wow</property>
          </and>
        </condition>
        <command>nasal</command>
        <script>controls.applyBrakes(0)</script>
      </binding>
    </mod-up>
  </button>

  <button n="1">
    <desc>PTT - Push To Talk (via VoIP)</desc>
    <binding>
      <command>nasal</command>
      <script>
        var m = get_modifiers();
        if (m == 4) aircraft.autotrim.start();
        else space(1, m);
      </script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>
          var m = get_modifiers();
          if (m == 4) aircraft.autotrim.stop();
          else space(0, m);
        </script>
      </binding>
    </mod-up>
  </button>

  <button n="4">
    <desc>Elevator trim down</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command>property-adjust</command>
      <property>/controls/flight/elevator-trim</property>
      <step type="double">-0.002</step>
    </binding>
  </button>

  <button n="5">
    <desc>Elevator trim up</desc>
    <repeatable type="bool">true</repeatable>
    <binding>
      <command>property-adjust</command>
      <property>/controls/flight/elevator-trim</property>
      <step type="double">0.002</step>
    </binding>
  </button>

  <button n="6">
    <desc>Flaps up</desc>
    <repeatable>false</repeatable>
    <binding>
      <command>nasal</command>
      <script>controls.flapsDown(-1)</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>controls.flapsDown(0)</script>
      </binding>
    </mod-up>
  </button>

  <button n="7">
    <desc>Flaps down</desc>
    <repeatable>false</repeatable>
    <binding>
      <command>nasal</command>
      <script>controls.flapsDown(1)</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>controls.flapsDown(0)</script>
      </binding>
    </mod-up>
  </button>


  <button n="2">
    <desc>Aileron trim left</desc>
    <repeatable>true</repeatable>
    <binding>
      <command>nasal</command>
      <script>controls.applyBrakes(1, -1)</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>controls.applyBrakes(0, -1)</script>
      </binding>
    </mod-up>
    <binding>
      <condition>
        <not>
          <property>/rotors/tail/rpm</property>
        </not>
      </condition>
      <command>property-adjust</command>
      <property>/controls/flight/aileron-trim</property>
      <step type="double">-0.001</step>
    </binding>
    <desc>Rudder for helis</desc>
    <binding>
      <condition>
        <property>/rotors/tail/rpm</property>
      </condition>
      <command>property-adjust</command>
      <property>/controls/flight/rudder</property>
      <step type="double">-0.01</step>
    </binding>
  </button>

  <button n="3">
    <desc>Aileron trim right</desc>
    <repeatable>true</repeatable>
    <binding>
      <command>nasal</command>
      <script>controls.applyBrakes(1, 1)</script>
    </binding>
    <mod-up>
      <binding>
        <command>nasal</command>
        <script>controls.applyBrakes(0, 1)</script>
      </binding>
    </mod-up>
    <binding>
      <condition>
        <not>
          <property>/rotors/tail/rpm</property>
        </not>
      </condition>
      <command>property-adjust</command>
      <property>/controls/flight/aileron-trim</property>
      <step type="double">0.001</step>
    </binding>
    <desc>Rudder for helis</desc>
    <binding>
      <condition>
        <property>/rotors/tail/rpm</property>
      </condition>
      <command>property-adjust</command>
      <property>/controls/flight/rudder</property>
      <step type="double">0.01</step>
    </binding>
  </button>

</PropertyList>