<?xml version="1.0"?>

<!-- 
************************************************************************
Default 4-axis joystick bindings.

* Axis 2: throttle
* Axes 3 and 4 (hat): view direction

* Button 1:  

Landing Gear Toggle


Assume that we have a conventional, four-axis, three/four-button
joystick, and that the first button is the trigger.
************************************************************************
-->

<PropertyList>

 <name>Analog 4-axis 4-button joystick</name>

<!--


 <axis n="0">
  <desc>Rudder</desc>
  <binding>
   <command>property-scale</command>
   <property>/controls/flight/rudder</property>
   <power type="double">2</power>
   <factor type="double">0.5</factor>
  </binding>
 </axis>


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

-->


  <axis n="3">
   <desc>View Direction</desc>
   <low>
    <repeatable>true</repeatable>
    <binding>
     <command>property-adjust</command>
     <property>/sim/current-view/goal-heading-offset-deg</property>
     <step type="double">1.0</step>
    </binding>
   </low>
   <high>
    <repeatable>true</repeatable>
    <binding>
     <command>property-adjust</command>
     <property>/sim/current-view/goal-heading-offset-deg</property>
     <step type="double">-1.0</step>
    </binding>
   </high>
  </axis>


  <axis n="4">
   <desc>View Elevation</desc>
   <low>
    <repeatable>true</repeatable>
    <binding>
     <command>property-adjust</command>
     <property>/sim/current-view/goal-pitch-offset-deg</property>
     <step type="double">1.0</step>
    </binding>
   </low>
   <high>
    <repeatable>true</repeatable>
    <binding>
     <command>property-adjust</command>
     <property>/sim/current-view/goal-pitch-offset-deg</property>
     <step type="double">-1.0</step>
    </binding>
   </high>
  </axis>


 <button n="1">
  <desc>View Cycle</desc>
  <repeatable>false</repeatable>
  <binding>
   <command>nasal</command>
   <script>view.stepView(1)</script>
  </binding>
 </button>


 <button n="3">
   
  <desc>autopilot Toggle</desc>
  <binding>
      <command>nasal</command>
      <script>citation.FD_set_mode("ap")</script>
  </binding>

  <binding>
   <command>nasal</command>
      <script>  gui.popupTip("Toggle autopilot");   </script>
  </binding>
  
 </button>



<!--
********  EXEMPLES (à voir, ne fonctionnent pas forcément... )**********



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

 <button n="1">
  <desc>Elevator trim up</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.elevatorTrim(1)</script>
  </binding>
 </button>


 <button n="3">
  <desc>stop autopilot</desc>

  <binding>
   <command>nasal</command>
      <script>
        var toggle_autopilot_on_off = func()
        {
            var ap = getprop("autopilot/switches/ap");
            var alt = getprop("autopilot/switches/alt");

            if (!ap and alt) {
                setprop("sim/messages/pilot",
                    "Cannot engage autopilot when altitude switch is on"
                );
                return;
            }
            setprop("autopilot/switches/ap", !ap);
        }
      </script>
  </binding>
  <binding>
   <command>nasal</command>
      <script>  gui.popupTip("Toggle autopilot");   </script>
  </binding>
  
 </button>


   <binding>
   
    <command>property-assign</command>
    <property>autopilot/switches/ap</property>
    <value>0</value>
  </binding>

    <desc>stop autopilot heading</desc>
    <repeatable>false</repeatable>
    <binding>
     <command>property-assign</command>
     <property>/autopilot/locks/heading</property>
     <value></value>
    </binding>

  <binding>
    <command>property-assign</command>
    <property>autopilot/controls/disconnect</property>
    <value>1</value>
  </binding>

    <desc>stop autopilot altitude</desc>
    <repeatable>false</repeatable>
    <binding>
     <command>property-assign</command>
     <property>/autopilot/locks/altitude</property>
     <value></value>
    </binding>

    <desc>stop autopilot speed</desc>
    <repeatable>false</repeatable>
    <binding>
     <command>property-assign</command>
     <property>/autopilot/locks/speed</property>
     <value></value>
    </binding>
-->
  
<!--


 <button n="3">
  <desc>Toggle autopilot altitude lock.</desc>
  <repeatable>false</repeatable>
  <binding>
   <command>property-toggle</command>
   <property>/autopilot/locks/altitude</property>

  </binding>
  <binding>
   <command>nasal</command>
      <script>   gui.popupTip("Toggle autopilot altitude");   </script>
  </binding>
 </button>
-->


<!--
<binding>
  <command>property-assign</command>
  <property>/autopilot/settings/target-speed-kt</property>
  <value>0</value>
</binding>
-->


 <!-- 

 <button n="1">
  <desc>Elevator trim up</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.elevatorTrim(1)</script>
  </binding>
 </button>

 <button n="2">
  <desc>Elevator trim down</desc>
  <repeatable type="bool">true</repeatable>
  <binding>
   <command>nasal</command>
   <script>controls.elevatorTrim(-1)</script>
  </binding>
 </button>

-->


</PropertyList>

<!-- end of joystick.xml -->
