Using a Nasal file with a joystick Part 2: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 22: Line 22:
     <binding>
     <binding>
       <command>nasal</command>
       <command>nasal</command>
       <script>saitekyoke.button1()</script>
       <script>nasfilename.button1()</script>
     </binding>
     </binding>
   </button>
   </button>
</syntaxhighlight>
</syntaxhighlight>
Of course, nasfilename is the name of your Nasal file.
If you have a modifier button, named ''mymod'', then do this
<syntaxhighlight lang="xml">
  <button n="xxx">
    <!-- Labled as 1 -->
    <desc>Whatever it does</desc>
    <binding>
      <command>nasal</command>
      <script>nasfilename.button1(mymod)</script>
    </binding>
  </button>
</syntaxhighlight>
If you use the keyboard Shift button as a modifier, you do this
<syntaxhighlight lang="xml">
  <button n="xxx">
    <!-- Labled as 1 -->
    <desc>Whatever it does</desc>
    <binding>
      <command>nasal</command>
      <script>nasfilename.button1(1)</script>
    </binding>
    <mod-shift>
      <binding>
      <command>nasal</command>
      <script>nasfilename.button1(2)</script>
      </binding>
    </mod-shift>
  </button>
</syntaxhighlight>





Revision as of 06:34, 4 February 2013

In Using a Nasal file with a joystick you saw how to get started. This article goes into it in more depth.


First Steps

Backup your xml file. Print it, you need to know which button does what. If you have a Nasal file, back it up too. If you haven't read the first part, read it and do the basic implementation now.


Modifying your xml file

This seems like a lot of work, but it is worth it in the end.

You need to use the labels of the buttons on your joystick. You will use these labels for the name of the Nasal function to call in your nasal file.

For each button in your xml file, change your code. Here, the button is labelled "1". And remember, we are talking about the label printed on the joystick, not the button number assigned by the operating system.

  <button n="xxx">
    <!-- Labled as 1 -->
    <desc>Whatever it does</desc>
    <binding>
      <command>nasal</command>
      <script>nasfilename.button1()</script>
    </binding>
  </button>

Of course, nasfilename is the name of your Nasal file.

If you have a modifier button, named mymod, then do this

  <button n="xxx">
    <!-- Labled as 1 -->
    <desc>Whatever it does</desc>
    <binding>
      <command>nasal</command>
      <script>nasfilename.button1(mymod)</script>
    </binding>
  </button>

If you use the keyboard Shift button as a modifier, you do this

  <button n="xxx">
    <!-- Labled as 1 -->
    <desc>Whatever it does</desc>
    <binding>
      <command>nasal</command>
      <script>nasfilename.button1(1)</script>
    </binding>
    <mod-shift>
      <binding>
      <command>nasal</command>
      <script>nasfilename.button1(2)</script>
      </binding>
    </mod-shift>
  </button>