<!-- Microsoft Microsoft SideWinder Precision Pro (USB)
  Joystick has four axes:
  axis 0: roll
  axis 1: pitch
  axis 2: yaw
  axis 3: throttle (reversed)

It has 9 buttons.
 b0  - fire
 b1  - secondary fire
 b2  - upper right thumb button
 b3  - lower right thumb button
 b4  - button A
 b5  - button B
 b6  - button C
 b7  - button D
 b8  - shift button

and a POV hat.
You can use the Hat<Position>(<hat_name>) function to trigger events,
where <Position> is one of
Centered/Up/Right/Down/Left/RightUp/RightDown/LeftUp/LeftDown
so e.g. HatDown(hat)
-->

<joystick>
  <input>
    <axis index="0" name="roll" limit="1.00" exponent="0.7" trim="0"/>
    <axis index="1" name="pitch" limit="1.00" exponent="0.7" trim="0"/>
    <axis index="2" name="yaw" limit="1.00" exponent="0.7" trim="0"/>
    <axis index="3" name="throttle"/>
    <button index="0" name="fire"/>
    <button index="1" name="fire2"/>
    <button index="2" name="up"/>
    <button index="3" name="down"/>
    <button index="4" name="A"/>
    <button index="5" name="B"/>
    <button index="6" name="C"/>
    <button index="7" name="D"/>
    <button index="8" name="shift"/>
    <hat index="0" name="hat"/>
  </input>

  <variables>
    <!-- manual by default and when pressing A, AUTO1 on B, AUTO2 on C -->
    <var name="mode" default="0"/>
    <set var="mode" value="0" on_event="A"/>
    <set var="mode" value="1" on_event="B"/>
    <set var="mode" value="2" on_event="C"/>
  </variables>

  <messages period="0.1">

    <message class="datalink" name="RC_4CH" send_always="true">
      <field name="mode" value="mode"/>
      <field name="throttle" value="Fit(-throttle,-127,127,0,127)"/>
      <field name="roll" value="roll"/>
      <field name="pitch" value="pitch"/>
      <field name="yaw" value="yaw"/>
    </message>

    <!-- go to "Start Engine" block if in AUTO2 and pressing shift + fire2 -->
    <message class="ground" name="JUMP_TO_BLOCK" on_event="(mode > 1) && shift && fire2">
      <field name="block_id" value="IndexOfBlock('Start Engine')"/>
    </message>

    <!-- go to "Takeoff" block if in AUTO2 and pressing shift + up -->
    <message class="ground" name="JUMP_TO_BLOCK" on_event="(mode > 1) && shift && up">
      <field name="block_id" value="IndexOfBlock('Takeoff')"/>
    </message>

    <!-- go to "land here" block if in AUTO2 and pressing shift + down -->
    <message class="ground" name="JUMP_TO_BLOCK" on_event="(mode > 1) && shift && down">
      <field name="block_id" value="IndexOfBlock('land here')"/>
    </message>

    <!-- kill throttle when pressing both fire buttons at the same time -->
    <message class="ground" name="DL_SETTING" on_event="fire && fire2">
      <field name="index" value="IndexOfSetting(autopilot.kill_throttle)"/>
      <field name="value" value="1"/>
    </message>

  </messages>
</joystick>
