Writing Joystick Code: Part 3: Difference between revisions

Jump to navigation Jump to search
m
Line 342: Line 342:


'''Method 1'''
'''Method 1'''
  <data>
<nowiki>  <data>
     <mode type="int">1</mode>  # Initialise mode to 1
     <mode type="int">1</mode>  # Initialise mode to 1
   </data>
   </data>
Line 348: Line 348:
   <nasal>
   <nasal>
     <script>
     <script>
       <nowiki><![CDATA[
       <![CDATA[
  var self = cmdarg().getParent();
  var self = cmdarg().getParent();
  var data = self.getNode("data");
  var data = self.getNode("data");
  var mode = data.getNode("mode");
  var mode = data.getNode("mode");
        get_mode = func { mode.getValue() }
          get_mode = func { mode.getValue(); }
       ]]></script>
       ]]>
    </script>
   </nasal>
   </nasal>
   
   
  var m  # Used whenever mode is accessed</nowiki>
    </nowiki>


This goes right at the top of your xml file, just after </name>.
This goes right at the top of your xml file, just after </name>.


The code for the button (non-repeatable)that changes mode looks like this
The code for the button (non-repeatable)that changes mode looks like this
   m = get_mode();
   var m = get_mode();
   m = m + 1;
   m = m + 1;
   if (m == 4) {
   if (m == 4) {
Line 369: Line 370:


When a button is pressed, the code looks like this
When a button is pressed, the code looks like this
   m = get_mode();
   var m = get_mode();
   if (m == 1) {
   if (m == 1) {
     ground-action
     ground-action
Line 426: Line 427:
be used somewhere in the system files. In the xml file for the Saitek Yoke, where I use a variable to control the assignments
be used somewhere in the system files. In the xml file for the Saitek Yoke, where I use a variable to control the assignments
of the levers on the quadrant, I call the variable ''SaitekMultiMode''. Unlikely to be used by the FG programmers, or anybody else.
of the levers on the quadrant, I call the variable ''SaitekMultiMode''. Unlikely to be used by the FG programmers, or anybody else.


=== perIndexAxisHandler ===
=== perIndexAxisHandler ===
648

edits

Navigation menu