Input device: Difference between revisions

Jump to navigation Jump to search
Information about using multiple mice on Linux
m (Joystick Config dialog is under File, not Help)
(Information about using multiple mice on Linux)
Line 483: Line 483:


* Sample code for firing weapons with the joystick is found on the [[Gun Effects]] page.
* Sample code for firing weapons with the joystick is found on the [[Gun Effects]] page.
== Multiple mice on Linux ==
On Linux, it is possible to make specific mice control specific Flightgear properties instead of the default flight controls.
You will need to know the Linux name and ID for the mouse. This can be done by running the command <code>xinput --list</code> which  lists all connected input devices. (Extra information about a specific device can be found with <code>xinput --list-props <id></code> or <code>xinput --list-props <name></code>.)
Then create a file in <code>fgdata/Input/Event/</code>. The leafname doesn't matter, but for example it could be called <code>fgdata/Input/Event/MouseExtra.xml</code>. The contents of this file determine the properties that the mouse will control. For example:
<pre>
<PropertyList>
  <name>Logitech Logitech USB Optical Mouse</name>
  <debug-events type="bool">false</debug-events>
  <grab type="bool">true</grab>
  <event>
    <desc>Y-Axis</desc>
    <name>rel-y-translate</name>
    <binding>
    <command>property-adjust</command>
    <property>/controls/flight/elevator</property>
    <factor type="double">-.002</factor>
    <min type="double">-1.0</min>
    <max type="double">1.0</max>
    <wrap type="bool">false</wrap>
    </binding>
  </event>
  <event>
    <desc>X-Axis</desc>
    <name>rel-x-translate</name>
    <binding>
    <command>property-adjust</command>
    <property>/controls/flight/aileron</property>
    <factor type="double">.002</factor>
    <min type="double">-1.0</min>
    <max type="double">1.0</max>
    <wrap type="bool">false</wrap>
    </binding>
  </event>
</PropertyList>
</pre>
(Change <code><name>Logitech Logitech USB Optical Mouse</name></code> to match your mouse.)
It can be useful to tell X to ignore the mouse so that it doesn't affect the main X pointer. This can be done with: <code>xinput --set-prop <id> "Device Enabled" 0</code>. Normal X handling of the mouse can be restored with <code>xinput --set-prop <id> "Device Enabled" 1</code>. (One can also use the name of the mouse instead of <code><id></code>.)
On Devuan Linux, one can use a udev rule to ensure that the mouse can be read and written by flightgear (usually they are only accessible to root): create a file <code>/etc/udev/rules.d/90-fgmouseextra.rules</code> containing a single line <code>KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0666"</code>. [Note that i know almost nothing about udev, and it's entirely possible that this represents a huge security flaw, so use with caution.]
[The information above is based on the forum thread https://forum.flightgear.org/viewtopic.php?t=32750 and Torsten Dreyer's original email https://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg23171.html.]


== Related content ==
== Related content ==
219

edits

Navigation menu