<?xml version="1.0"?>
<!--
************************************************************************
Genius F-31U VIBRATION USB Joystick

Axes:
0 - Aileron
1 - Elevator
2 - Rudder
3 - Throttle
4 - View left-right Hat
5 - View up-down Hat

Buttons:
0 - Brakes
1 - Cycle view
2 - Elevator trim up
3 - Elevator trim down
4 - Flaps down
5 - Flaps up
6 - Brakes
7 - Mixture richer
8 - Mixture leaner
9 - Landing Gear Toggle
************************************************************************
-->
<PropertyList>
    <name type="string">Padix Co. Ltd. 10-Button USB Joystick</name>  <!-- GNU/Linux. -->
    <name type="string">10-Button USB Joystick with Vibration</name>  <!-- Windows with vibration driver.-->
    <name type="string">10-Button USB Joystick</name>                 <!-- Windows without vibration driver.-->

    <axis n="0">
        <desc>Aileron</desc>
        <binding>
            <command>property-scale</command>
            <property>/controls/flight/aileron</property>
            <power type="int">2</power>
        </binding>
    </axis>

    <axis n="1">
        <desc>Elevator</desc>
        <binding>
            <command>property-scale</command>
            <property>/controls/flight/elevator</property>
            <power type="int">2</power>
            <factor type="double">-1.0</factor> <!-- Reverse axis. -->
        </binding>
    </axis>

    <axis>
        <desc>Rudder</desc>
        <number>
            <unix>2</unix>
            <windows>3</windows>
        </number>
        <binding>
            <command>property-scale</command>
            <property>/controls/flight/rudder</property>
            <power type="int">2</power>
            <factor type="double">-1.0</factor> <!-- Reverse axis. -->
        </binding>
    </axis>

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

    <axis>
        <desc>View Direction</desc>
        <number>
            <unix>4</unix>
            <windows>6</windows>
        </number>
        <low>
            <desc>View left</desc>
            <repeatable>true</repeatable>
            <binding>
                <!--
                This also works, but LookAt views has inverted left/right.
                <command>property-adjust</command>
                <property>/sim/current-view/goal-heading-offset-deg</property>
                <step type="double">3.0</step>
                -->
                <command>nasal</command>
                <script>
                    var valueDelta = -3.0;
                    if (getprop("/sim/current-view/type") == "lookat")
                    {
                        valueDelta = 3.0;
                    }
                    setprop("/sim/current-view/heading-offset-deg", getprop("/sim/current-view/heading-offset-deg") - valueDelta);
                </script>
            </binding>
        </low>
        <high>
            <desc>View right</desc>
            <repeatable>true</repeatable>
            <binding>
                <!--
                This also works, but LookAt views has inverted left/right.
                <command>property-adjust</command>
                <property>/sim/current-view/goal-heading-offset-deg</property>
                <step type="double">-3.0</step>
                -->
                <command>nasal</command>
                <script>
                    var valueDelta = -3.0;
                    if (getprop("/sim/current-view/type") == "lookat")
                    {
                        valueDelta = 3.0;
                    }
                    setprop("/sim/current-view/heading-offset-deg", getprop("/sim/current-view/heading-offset-deg") + valueDelta);
                </script>
            </binding>
        </high>
    </axis>

    <axis>
        <desc>View Elevation</desc>
        <number>
            <unix>5</unix>
            <windows>7</windows>
        </number>
        <low>
            <desc>View down</desc>
            <repeatable>true</repeatable>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/goal-pitch-offset-deg</property>
                <step type="double">3.0</step> <!-- Use -3.0 for Windows. -->
            </binding>
        </low>
        <high>
            <desc>View up</desc>
            <repeatable>true</repeatable>
            <binding>
                <command>property-adjust</command>
                <property>/sim/current-view/goal-pitch-offset-deg</property>
                <step type="double">-3.0</step> <!-- Use 3.0 for Windows. -->
            </binding>
        </high>
    </axis>


    <button n="0">
        <desc>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>

    <button n="1">
        <desc>Cycle View</desc>
        <repeatable>false</repeatable>
        <binding>
            <command>nasal</command>
            <script>
                view.stepView(1);
                #gui.popupTip(sprintf("View index: %d, view type: %s", getprop("sim/current-view/view-number"), getprop("/sim/current-view/type")));
            </script>
        </binding>
    </button>

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

    <button n="4">
        <desc>Flaps down</desc>
        <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="5">
        <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="6">
        <desc>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>

    <button n="7">
        <desc>Mixture richer</desc>
        <repeatable>true</repeatable>
        <binding>
            <command>nasal</command>
            <script>controls.adjMixture(1)</script>
        </binding>
    </button>

    <button n="8">
        <desc>Mixture leaner</desc>
        <repeatable>true</repeatable>
        <binding>
            <command>nasal</command>
            <script>controls.adjMixture(-1)</script>
        </binding>
    </button>

    <button n="9">
        <desc>Landing Gear Toggle</desc>
        <repeatable>false</repeatable>
        <binding>
            <command>nasal</command>
            <script>controls.gearToggle()</script>
        </binding>
    </button>

</PropertyList>