Writing Joystick Code: Part 3: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
No edit summary
mNo edit summary
Line 7: Line 7:


-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
To toggle the Parking brake, use this. Entire code-block shown. Non-repeatable button.
To toggle the Parking brake, use this. Entire code-block shown. Non-repeatable button. (You have to specifically set <repeatable> to true if you want repeatable. It is assumed to be false.
(You have to specifically set <repeatable> to true if you want repeatable. It is assumed to be false.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
   <button n="1">
   <button n="1">
Line 18: Line 17:
   </button>
   </button>
</syntaxhighlight>  
</syntaxhighlight>  
This method can be used to toggle any property that is on/off.
This method can be used to toggle any property that is on/off. Use Debug - Browse Internal Properties to find suitable candidates.  
Use Debug - Browse Internal Properties to find suitable candidates.  
Also see getProp, setProp and setAll below.
Also see getProp, setProp and setAll below.
   
   
Remember, it ''toggles'' the property, you can't use it to set the property into a specific state.
Remember, it ''toggles'' the property, you can't use it to set the property into a specific state.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
To make condition work with mixture on a lever (axis). This is pertinent to turboprops.
Change
<pre style="white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word">
  controls.mixtureAxis()
</pre>
to
<pre style="white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word">
  controls.mixtureAxis();
  props.setAll("controls/engines/engine", "condition", getprop("controls/engines/engine/mixture"))
</pre>
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
To make condition work with mixture on a lever (axis). This is pertinent to turboprops.
Change
    controls.mixtureAxis()
to
    controls.mixtureAxis();
    props.setAll("controls/engines/engine", "condition", getprop("controls/engines/engine/mixture"))
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
  To make condition work with mixture on a non-repeatable button.
  To make condition work with mixture on a non-repeatable button.
Line 68: Line 80:
   ]]>
   ]]>
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
 
-----------------------------------------------------------------------------
 
This is an alternative method to adjust a property
This is an alternative method to adjust a property
   <repeatable>true</repeatable>
   <repeatable>true</repeatable>
Line 78: Line 89:
   </binding>
   </binding>
This will continuously reduce /sim/current-view/goal-pitch-offset-deg in steps of 2 while the button is held in.
This will continuously reduce /sim/current-view/goal-pitch-offset-deg in steps of 2 while the button is held in.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------


== Advanced Programming ==
== Advanced Programming ==
224

edits

Navigation menu