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

From FlightGear wiki
Jump to navigation Jump to search
(Created page with "In Using a Nasal file with a joystick you saw how to get started. This article goes into it in more depth. Category:Howto Category:Hardware")
 
mNo edit summary
Line 1: Line 1:
In [[Using a Nasal file with a joystick]] you saw how to get started. This article goes into it in more depth.
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.
<syntaxhighlight=php>
  <button n="xxx">
    <!-- Labled as 1 -->
    <desc>Whatever it does</desc>
    <binding>
      <command>nasal</command>
      <script>saitekyoke.button1()</script>
    </binding>
  </button>
</syntaxhighlight>





Revision as of 06:26, 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. <syntaxhighlight=php>

 <button n="xxx">
   <desc>Whatever it does</desc>
   <binding>
     <command>nasal</command>
     <script>saitekyoke.button1()</script>
   </binding>
 </button>

</syntaxhighlight>