<!-- Logitech F710
  This config is for Xinput mode. Make sure slider switch on back of controller is on X (not D)
  Also make sure controller not in sports mode (mode light should be off)

  Joystick has eight axes:
  axis 0: X on left stick
  axis 1: Y on left stick
  axis 2: Left trigger
  axis 3: X on right stick
  axis 4: Y on right stick
  axis 5: Right trigger
  axis 6: X on D-Pad (not analog)
  axis 7: Y on D-Pad (not analog)

It has 8 buttons.
 b_green  - green button (A)
 b_red  - red button (B)
 b_blue  - blue button (X)
 b_yellow  - yellow button (Y)
 b_ltb - left trigger button
 b_rtb - right trigger button
 b_start - start button
 b_back - back button

-->

<joystick>
 <input>
  <axis index="0" name="lx" limit="1.00" exponent="0.7" trim="0"/>
  <axis index="1" name="ly" limit="1.00" exponent="0.0" trim="0"/>
  <axis index="2" name="lt" limit="1.00" exponent="0.0" trim="0"/>
  <axis index="3" name="rx" limit="1.00" exponent="0.7" trim="0"/>
  <axis index="4" name="ry" limit="1.00" exponent="0.7" trim="0"/>
  <axis index="5" name="rt" limit="1.00" exponent="0.0" trim="0"/>
  <axis index="6" name="dx" limit="1.00" exponent="0.0" trim="0"/>
  <axis index="7" name="dy" limit="1.00" exponent="0.0" trim="0"/>
  <button index="0" name="b_green"/>
  <button index="1" name="b_red"/>
  <button index="2" name="b_blue"/>
  <button index="3" name="b_yellow"/>
  <button index="4" name="b_ltb"/>
  <button index="5" name="b_rtb"/>
  <button index="6" name="b_start"/>
  <button index="7" name="b7"/>
  <button index="8" name="b8"/>
  <button index="9" name="b9"/>
  <button index="10" name="b_back"/>
</input>

<messages period="0.0333333333">


  <message class="datalink" name="RC_4CH" send_always="true">
   <field name="joystick_id" value="JoystickID()"/>
   <field name="throttle"    value="Bound(0-ly,0,127)"/>
   <field name="roll"        value="rx"/>
   <field name="yaw"         value="lx"/>
   <field name="pitch"       value="ry"/>
  </message>


  <!-- trim commands -->
  <message class="ground" name="DL_SETTING_MOD" on_event="dx > 100">
    <field name="index" value="IndexOfSetting('rc_roll_trim')"/>
    <field name="mod" value="10"/>
  </message>
  <message class="ground" name="DL_SETTING_MOD" on_event="0-dx > 100"	>
    <field name="index" value="IndexOfSetting('rc_roll_trim')"/>
    <field name="mod" value="0-10"/>
  </message>

  <message class="ground" name="DL_SETTING_MOD" on_event="dy > 100">
    <field name="index" value="IndexOfSetting('rc_pitch_trim')"/>
    <field name="mod" value="10"/>
  </message>
  <message class="ground" name="DL_SETTING_MOD" on_event="0-dy > 100">
    <field name="index" value="IndexOfSetting('rc_pitch_trim')"/>
    <field name="mod" value="0-10"/>
  </message>

  <message class="ground" name="DL_SETTING_MOD" on_event="b_rtb">
    <field name="index" value="IndexOfSetting('rc_yaw_trim')"/>
    <field name="mod" value="10"/>
  </message>
  <message class="ground" name="DL_SETTING_MOD" on_event="b_ltb">
    <field name="index" value="IndexOfSetting('rc_yaw_trim')"/>
    <field name="mod" value="0-10"/>
  </message>

  <message class="ground" name="DL_SETTING" on_event="b_ltb && b_rtb">
    <field name="index" value="IndexOfSetting('rc_roll_trim')"/>
    <field name="value" value="0"/>
  </message>

  <message class="ground" name="DL_SETTING" on_event="b_ltb && b_rtb">
    <field name="index" value="IndexOfSetting('rc_pitch_trim')"/>
    <field name="value" value="0"/>
  </message>

  <message class="ground" name="DL_SETTING" on_event="b_ltb && b_rtb">
    <field name="index" value="IndexOfSetting('rc_yaw_trim')"/>
    <field name="value" value="0-10"/>
  </message>
<!--
  <message class="ground" name="lx" on_event="b8"/>
  <message class="trim_plus" name="ly" on_event="b10"/>
  <message class="trim_minus" name="ly" on_event="b11"/>
  <message class="trim_plus" name="rx" on_event="b2"/>
  <message class="trim_minus" name="rx" on_event="b0"/>
  <message class="trim_minus" name="ry" on_event="b3"/>
  <message class="trim_plus" name="ry" on_event="b1"/>
  <message class="trim_save" name="" on_event="b5"/>
-->

<!-- Camera switch. Currently uses same buttons as yaw trim -->

  <message class="ground" name="DL_SETTING" on_event="b_start">
    <field name="index" value="IndexOfSetting('cam_switch')"/>
    <field name="value" value="1"/>
  </message>

  <message class="ground" name="DL_SETTING" on_event="b_back">
    <field name="index" value="IndexOfSetting('cam_switch')"/>
    <field name="value" value="0"/>
  </message>


  <!-- Red Button -->  <!-- AUTO2 mode -->
  <message class="ground" name="DL_SETTING" on_event="b_red">
    <field name="index" value="IndexOfSetting('pprz_mode')"/>
    <field name="value" value="2"/>
  </message>

  <!-- Yellow Button -->   <!-- AUTO1 mode -->
  <message class="ground" name="DL_SETTING" on_event="b_yellow">
    <field name="index" value="IndexOfSetting('pprz_mode')"/>
    <field name="value" value="1"/>
  </message>

  <!-- Green Button -->  <!-- MANUAL mode -->
  <message class="ground" name="DL_SETTING" on_event="b_green">
    <field name="index" value="IndexOfSetting('pprz_mode')"/>
    <field name="value" value="0"/>
  </message>

 <message class="ground" name="DL_SETTING" on_event="b_green || b_yellow || b_red">
    <field name="index" value="IndexOfSetting('rc_dl_active_joystick')"/>
    <field name="value" value="JoystickID()"/>
  </message>

</messages>

</joystick>
