<?xml version="1.0"?>

<PropertyList>
	<nasal>
		<open><![CDATA[

var assignAxis = func(cmd) {

  var i = getprop("/sim/gui/dialogs/joystick-config/current-axis");
  setprop("/sim/gui/dialogs/joystick-config/axis[" ~ i ~ "]/binding", cmd);

  joystick.writeConfig();
  fgcommand("reinit", props.Node.new({"subsystem": "input"}));
  fgcommand("dialog-close", props.Node.new({"dialog-name": "button-axis-config"}));
  fgcommand("dialog-close", props.Node.new({"dialog-name": "joystick-config"}));
  fgcommand("dialog-show", props.Node.new({"dialog-name": "joystick-config"}));
}
		]]></open>

		<close><![CDATA[
		]]></close>
	</nasal>


	<name>button-axis-config</name>
	<layout>vbox</layout>
	<resizable>true</resizable>
	<modal>true</modal>
	<default-padding>3</default-padding>

	<group>
		<layout>hbox</layout>
		<default-padding>1</default-padding>

		<empty><stretch>true</stretch></empty>

		<text>
			<label>Joystick Axis Configuration</label>
		</text>

		<empty><stretch>true</stretch></empty>

		<button>
			<legend></legend>
			<key>Esc</key>
			<pref-width>16</pref-width>
			<pref-height>16</pref-height>
			<border>2</border>
			<binding>
				<command>dialog-close</command>
			</binding>
		</button>
	</group>

	<hrule/>

	<text>
	  <halign>left</halign>
	  <label>Select the operation to assign to this axis.</label>
  </text>

  <hrule/>

  <group>
    <layout>table</layout>

    <text>
      <row>0</row>
      <col>0</col>
      <label>Flight Controls</label>
    </text>

    <button>
      <row>1</row>
      <col>0</col>
      <halign>fill</halign>
      <legend>Aileron</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Aileron");
        </script>
      </binding>
    </button>

    <button>
      <row>2</row>
      <col>0</col>
      <halign>fill</halign>
      <legend>Elevator</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Elevator");
        </script>
      </binding>
    </button>

    <button>
      <row>3</row>
      <col>0</col>
      <halign>fill</halign>
      <legend>Rudder</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Rudder");
        </script>
      </binding>
    </button>

    <button>
      <row>4</row>
      <col>0</col>
      <halign>fill</halign>
      <legend>Brake Left</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Brake Left");
        </script>
      </binding>
    </button>

    <button>
      <row>5</row>
      <col>0</col>
      <halign>fill</halign>
      <legend>Brake Right</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Brake Right");
        </script>
      </binding>
    </button>

 
    <text>
      <row>0</row>
      <col>3</col>
      <label>Trim</label>
    </text>


   <button>
      <row>1</row>
      <col>3</col>
      <halign>fill</halign>
      <legend>Aileron Trim to position</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Aileron Trim");
        </script>
      </binding>
    </button>
    <button>
      <row>2</row>
      <col>3</col>
      <halign>fill</halign>
      <legend>Elevator Trim to position</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Elevator Trim");
        </script>
      </binding>
    </button>
    <button>
      <row>3</row>
      <col>3</col>
      <halign>fill</halign>
      <legend>Rudder Trim to position</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Rudder Trim");
        </script>
      </binding>
    </button>


   <button>
      <row>4</row>
      <col>3</col>
      <halign>fill</halign>
      <legend>Aileron Trim Incremental</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Aileron Trim Incremental");
        </script>
      </binding>
    </button>
    <button>
      <row>5</row>
      <col>3</col>
      <halign>fill</halign>
      <legend>Elevator Trim Incremental</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Elevator Trim Incremental");
        </script>
      </binding>
    </button>
    <button>
      <row>6</row>
      <col>3</col>
      <halign>fill</halign>
      <legend>Rudder Trim Incremental</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Rudder Trim Incremental");
        </script>
      </binding>
    </button>



    <text>
      <row>0</row>
      <col>1</col>
      <label>Engines</label>
    </text>

    <button>
      <row>1</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Throttle All Engines</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Throttle All Engines");
        </script>
      </binding>
    </button>

    <button>
      <row>2</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Mixture All Engines</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Mixture All Engines");
        </script>
      </binding>
    </button>

    <button>
      <row>3</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Propeller All Engines</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Propeller All Engines");
        </script>
      </binding>
    </button>

    <button>
      <row>4</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Throttle Engine 0</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Throttle Engine 0");
        </script>
      </binding>
    </button>

    <button>
      <row>5</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Mixture Engine 0</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Mixture Engine 0");
        </script>
      </binding>
    </button>

    <button>
      <row>6</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Propeller Pitch Engine 0</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Propeller Pitch Engine 0");
        </script>
      </binding>
    </button>
    <button>
      <row>7</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Throttle Engine 1</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Throttle Engine 1");
        </script>
      </binding>
    </button>
    <button>
      <row>8</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Mixture Engine 1</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Mixture Engine 1");
        </script>
      </binding>
    </button>
 
    <button>
      <row>9</row>
      <col>1</col>
      <halign>fill</halign>
      <legend>Propeller Pitch Engine 1</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("Propeller Pitch Engine 1");
        </script>
      </binding>
    </button>
 
    <text>
      <row>0</row>
      <col>2</col>
      <label>Other</label>
    </text>

    <button>
      <row>1</row>
      <col>2</col>
      <halign>fill</halign>
      <legend>View (horizontal)</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("View (horizontal)");
        </script>
      </binding>
    </button>

    <button>
      <row>2</row>
      <col>2</col>
      <halign>fill</halign>
      <legend>View (vertical)</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("View (vertical)");
        </script>
      </binding>
    </button>

    <button>
      <row>3</row>
      <col>2</col>
      <halign>fill</halign>
      <legend>View Horizontal Axis</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("View Horizontal Axis");
        </script>
      </binding>
    </button>

    <button>
      <row>4</row>
      <col>2</col>
      <halign>fill</halign>
      <legend>View Vertical Axis</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("View Vertical Axis");
        </script>
      </binding>
    </button>



  </group>

  <group>
    <empty>
      <stretch>true</stretch>
    </empty>
    <layout>hbox</layout>

    <button>
      <row>5</row>
      <col>2</col>
      <halign>fill</halign>
      <legend>Remove assignment</legend>
      <binding>
        <command>nasal</command>
        <script>
          assignAxis("None");
        </script>
      </binding>
    </button>

    <button>
      <legend>Close</legend>
      <default>true</default>
      <key>Esc</key>
      <binding>
        <command>dialog-close</command>
      </binding>
    </button>
    <empty>
      <stretch>true</stretch>
    </empty>
  </group>

</PropertyList>