Board index FlightGear Support Hardware

Two mice - two different usages: How to enable this feature?  Topic is solved

Joysticks, pedals, monitors.

Two mice - two different usages: How to enable this feature?

Postby dream_flyer » Sat Aug 19, 2017 12:49 am

Hello all!

I'm completely new to FG, but I already had my first flight yesterday :) Awesome! :) Thanks!

I want a second mouse to control the rudder (and the primary mouse will be the yoke). I found Torsten's instructions. Is that way still supported?

He says there is a --with-eventinput option, but the INSTALL file suggests to use cmake, and there is no (global) configure script in the source tree. So, where do I specify this option?

I tried to follow instructions with my default-compiled binary: created a file (msm.xml) in data/Input/Event as Torsten wrote, replacing name to what lsusb showed. No effect: both mice function the same.

FG version 2017.2.1, Debian 9 Stretch. Thanks.
Last edited by dream_flyer on Sat Aug 19, 2017 3:58 pm, edited 1 time in total.
dream_flyer
 
Posts: 10
Joined: Sat Aug 19, 2017 12:19 am

Re: Two mice - two different usages: How to enable this feat

Postby dream_flyer » Sat Aug 19, 2017 9:18 am

UPDATE:

I discovered the -L option for cmake (here). After running cmake -DEVENT_INPUT:BOOL=ON .. -DCMAKE_BUILD_TYPE=Release, made sure CMakeCache.txt now has the line EVENT_INPUT:BOOL=ON. Re-compiled, re-installed. As a test, I changed signs for factor (inversion) in the xml. No effect. I also tried to change name of the mouse from Microsoft Corp. Basic Optical Mouse v2.0 to simply Microsoft (as it is the only MS product on my PC).

No clues from --log-level=1 fgfs option. Where can I see that FG is really applying my xml config? (or why it does not). Thanks.
Last edited by dream_flyer on Sat Aug 19, 2017 4:00 pm, edited 2 times in total.
dream_flyer
 
Posts: 10
Joined: Sat Aug 19, 2017 12:19 am

Re: Two mice - two different usages: How to enable this feat

Postby wkitty42 » Sat Aug 19, 2017 10:36 am

i'm surprised you were able to get --log-level=1 to go... i thought that only words were allowed for the log level... according to the wiki, only bulk, debug, info, warn and alert are available... try --log-level=debug...

as for changing the name of the mouse, you probably can't really do that because FG takes what the device reports itself as... IME, if there's no match, it won't work...

i don't have another mouse handy to try this with but since that post you refer to is from 2009, i would expect this to still be available... in the property tree, it should show up under /input or maybe /input/mice... when you're in the sim, use the "/" key to bring up the property tree where you can scroll down to the input branch...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Two mice - two different usages: How to enable this feat

Postby dream_flyer » Sat Aug 19, 2017 12:32 pm

Thank you!

(the value 1 is from fgfs man page)

I edited (broke) some xml files and I see parse failure reading:Path... in the log (even at default verbosity). However, no such parse error when I edit (break) my msm.xml, or even the supplied fgdata/Input/Event/GoFlight/EFIS.xml. Looking at debug (the value you suggested) output, I can see FG reading all the xml files from Joysticks directory, but it does not even try to read xmls from the Event (or Keyboard)!

I put (not broken) msm.xml in Joysticks, and I see the normal info message NavCache: no rebuild required for Path ...data/Input/Joysticks/msm.xml, but it makes no changes - mice behave the same.

So, where to put that xml file? And how to find out the mouse name which FG uses to identify the mouse?

As to property tree - there is only one entry, mouse, under /input/mice, independent of whether the second mouse is plugged in or not (I restarted FG in each case; and the below properties also seem to be same).
dream_flyer
 
Posts: 10
Joined: Sat Aug 19, 2017 12:19 am

Re: Two mice - two different usages: How to enable this feat

Postby wkitty42 » Sat Aug 19, 2017 7:34 pm

dream_flyer wrote in Sat Aug 19, 2017 12:32 pm:I put (not broken) msm.xml in Joysticks, and I see the normal info message NavCache: no rebuild required for Path ...data/Input/Joysticks/msm.xml, but it makes no changes - mice behave the same.

yeah, that scan is from the navcache building/updating routine... it doesn't do anything with any of those files... i don't know why it is traipsing through that and other unrelated directories when it should, IMHO, be looking only in the directories where navigation data files are found...

let's see if anyone else chimes in in the next few days... i'm curious to see what Torsten Dreyer has to say, if anything, but i think he's on vacation till the end of the month...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Two mice - two different usages: How to enable this feat  

Postby slawekmikula » Mon Sep 04, 2017 4:25 pm

Thanks dream_flyer for tip, that this kind of functionality does indeed exists. When I travel only with my laptop, it would be much feasible to carry second small mouse and fly with this. Anyway, in the weekend i had some free time and dig into fg sourcecode and try to run it. Indeed it works, and it works (of course for me!) quite nice.

How to run this:
  • use linux - it works only in linux environment
  • compile flightgear with flag -DEVENT_INPUT=ON (helper scripts find below the list)
  • find correct identifier for the mouse. Easiest way is to unplug and plug it again. In "dmesg" command you can see something like "Logitech Unifying Device. Wireless PID:1017". This is the name for the event catch.
  • make sure you have write permission for event file in /dev/input ! It is a must ! eg. ls -l /dev/input and make sure that you (your user) have write permission for events. To check which event is this new mouse plug/unplug it.
  • create event file in your fghome directory under Input/Event directory (can be in subdirectory). Example just below. I have Logitech Anywhere MX and I configure scroll as a throtle, middle mouse as a view recenter and additional buttons as flaps up/down.
  • run flightgear. When the 3D is running, your control mouse should stop responding to cursor events and is a fully stable controller. Second mouse can be used as a normal mouse).
  • of course this can be extended to another mices (eg. trackpads) for e.g. trimming the plane.
  • i'm using it with the helihud HUD http://wiki.beggabaur.rocks/ya/HeliHUD in order to know what is the position of the mouse/yoke when looking around.
  • have fun :)

Output from dmesg command:

Code: Select all
[133959.624573] logitech-djreceiver 0003:046D:C52B.0032: hiddev0,hidraw0: USB HID v1.11 Device [Logitech USB Receiver] on usb-0000:00:14.0-1/input2
[133959.627210] input: Logitech Unifying Device. Wireless PID:1017 as /devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.2/0003:046D:C52B.0032/input/input41
[133959.627704] logitech-djdevice 0003:046D:C52B.0033: input,hidraw1: USB HID v1.11 Mouse [Logitech Unifying Device. Wireless PID:1017] on usb-0000:00:14.0-1:1


My flightgear build command. Most important is -DEVENT_INPUT=ON

Code: Select all
#!/bin/bash

cd flightgear
git pull
cd ..

rm -rf ./fgbuild
mkdir fgbuild
cd fgbuild

cmake ../flightgear -DEVENT_INPUT=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH="../fgbin"
make -j2 install


My Event file (this file is for my two mices and i can choose which one by commenting/uncomment their names)

Code: Select all
<PropertyList>
  <!--<name>Microsoft Microsoft® Nano Transceiver v2.0</name> -->
  <name>Logitech Unifying Device. Wireless PID:1017</name>
  <debug-events type="bool">true</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>
  <event>
    <desc>Wheel</desc>
    <name>rel-wheel</name>
    <binding>
     <command>property-adjust</command>
     <property>/controls/engines/engine/throttle</property>
     <factor type="double">0.05</factor>
     <min type="double">0.0</min>
     <max type="double">1.0</max>
     <wrap type="bool">false</wrap>
    </binding>
  </event>
  <event>
    <desc>Left button</desc>
    <name>button-left</name>
    <repeatable type="string">true</repeatable>
    <binding>
      <command type="string">nasal</command>
      <script type="string">controls.applyBrakes(1);</script>
    </binding>
  </event>
  <event>
    <desc>Wheel Button</desc>
    <name>button-middle</name>
    <binding>
     <command>nasal</command>
     <script type="string">
      <![CDATA[

          #Reset zoom
          interpolate("/sim/current-view/field-of-view", getprop("/sim/current-view/config/default-field-of-view-deg"), 0.3);
          #Center view
          interpolate("/sim/current-view/goal-pitch-offset-deg", getprop("/sim/current-view/config/pitch-offset-deg"), 0.3);

          if( getprop("/sim/current-view/goal-heading-offset-deg") < 180 )
            interpolate("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/config/heading-offset-deg"), 0.3);
          else
          {
            #If the view is shifted right when it is centered, it will take the longest path around
            #so we need to do some calculations to return the view to the configured default within the
            #same amount of time (.3 seconds) but going in the logical direction -- the quickest path.
            #
            var distanceright = (360 - getprop("/sim/current-view/goal-heading-offset-deg"));
            var distance = distanceright + getprop("/sim/current-view/config/heading-offset-deg");
            var percentright = distanceright / distance;
            interpolate("/sim/current-view/goal-heading-offset-deg", 360, percentright);
            setprop("/sim/current-view/goal-heading-offset-deg", 0);
            interpolate("/sim/current-view/goal-heading-offset-deg", getprop("/sim/current-view/config/heading-offset-deg"), 0.3 * (1 - percentright));
          }
      ]]>
    </script>
    </binding>
  </event>
  <event>
    <desc>Button 4</desc>
    <name>button-extra</name>
    <repeatable type="string">false</repeatable>
    <binding>
     <command>nasal</command>
     <script type="string">
      <![CDATA[
        controls.flapsDown(-1);
      ]]>
    </script>
    </binding>
  </event>
  <event>
    <desc>Button 5</desc>
    <name>button-side</name>
    <repeatable type="string">false</repeatable>
    <binding>
     <command>nasal</command>
     <script type="string">
      <![CDATA[
        controls.flapsDown(1);
      ]]>
    </script>
    </binding>
  </event>

</PropertyList>



Sample output from the debug log from FlightGear.

Code: Select all
Logitech Unifying Device. Wireless PID:1017 has event misc-scan modifiers=0 value=589829
Logitech Unifying Device. Wireless PID:1017 has event button-extra modifiers=0 value=0



PS. If this should go into wiki, maybe someone from more experienced guys give me advice where this tips should go (new article? addendum ?)
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Two mice - two different usages: How to enable this feat

Postby dream_flyer » Tue Sep 05, 2017 10:47 pm

slawekmikula - wonderful! Good job. Thank you for confirming the location of the xml, and the way to determine the mouse name (dmesg). And most importantly - for the /dev/input/event permissions!

I found what my problem was. I didn't notice error message from cmake, "UDev not found, event input is disabled!". I installed libudev-dev (among some other libs), and now it works fine.

Now I do see the "Reading device file" messages when FG is parsing xmls in Input/Event dir. There's the /input/event dir in FG (accessible with "/"), with the configured mouse in it (two devices actually, but the same mouse). The /devices/status/mice dir however, contains only one mouse.
dream_flyer
 
Posts: 10
Joined: Sat Aug 19, 2017 12:19 am

Re: Two mice - two different usages: How to enable this feat

Postby slawekmikula » Wed Sep 06, 2017 9:13 am

No problem :) Do you have any other issues with this ?
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Two mice - two different usages: How to enable this feat

Postby dream_flyer » Thu Sep 07, 2017 8:03 pm

Actually, yes.. Thank you. About your xml config, the throttle on the "rel-wheel" mouse event. It works - but only momentarily (as seen in /controls/engines/engine/throttle): the value immediately goes back to what I set with PgUp/PgDn. What/where setting do you have to really "apply" the change?

Whoever may read this thread: spaces (even a trailing one) in the mouse name are important.
dream_flyer
 
Posts: 10
Joined: Sat Aug 19, 2017 12:19 am

Re: Two mice - two different usages: How to enable this feat

Postby slawekmikula » Fri Sep 08, 2017 10:33 am

I was testing throttle on cessna 172 (and AFAIR 182). I fly mostly GA planes and it works there. I think you should look into property tree of the selected aircraft (/ button) and try to change some property to find if this works. Next modify event mapping in xml to control proper values.
slawekmikula
 
Posts: 128
Joined: Sun Feb 19, 2017 10:31 am

Re: Two mice - two different usages: How to enable this feat

Postby cgdae » Sat Jul 13, 2019 11:07 am

I've been wanting to use a second mouse to control the rudder for ages, and have only just come across this thread.

I don't think think the flightgear wiki has anything about this? Unless anyone suggests otherwise, i might have a look at adding something in the next few days.

Some additional bits of information that might be useful:

Current flightgear (branch 'next') appears to support this by default - there's no need to rebuild with 'flag -DEVENT_INPUT=ON'.

On linux, you can get a list of input devices with: 'xinput --list', and show information about a specific device with 'xinput --list-props <id>' or 'xinput --list-props <name>'.

If one has an extra mouse working in flightgear, it can be useful to tell X to ignore it, so that it doesn't affect the main X pointer. This can be done with: 'xinput --set-prop <id> "Device Enabled" 0'. Normal X handling of the mouse can be restored with 'xinput --set-prop <id> "Device Enabled" 1'.

On my Devuan system, i use a udev rule to ensure that my second mouse can be read and written by flightgear (usually they are only accessible to root): create a file '/etc/udev/rules.d/90-fgmouseextra.rules' containing a single line 'KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0666"'. Note that i know almost nothing about udev, and it's entirely possible that this represents a huge security flaw, so use with caution.
cgdae
 
Posts: 117
Joined: Tue May 31, 2016 8:35 pm

Re: Two mice - two different usages: How to enable this feat

Postby cgdae » Wed Aug 05, 2020 9:55 am

Ages ago i updated the wiki with details about how to use multiple mice on Linux, but forgot to mention it here.

So here's the link: http://wiki.flightgear.org/Input_device ... e_on_Linux

Please update that wiki page with any corrections / new information.
cgdae
 
Posts: 117
Joined: Tue May 31, 2016 8:35 pm

Re: Two mice - two different usages: How to enable this feat

Postby innactpro » Thu May 25, 2023 4:38 am

Realizing it has been a few years since the last post, recently trying to add a second mouse results in a Fatal exception std::exception.

It only seems to happen when <name></name> in the xml for the second mouse contains the device name listed in xinput.
User avatar
innactpro
 
Posts: 54
Joined: Fri May 19, 2023 2:27 pm
Version: 2020.3.18
OS: Ubuntu 22.04 LTS


Return to Hardware

Who is online

Users browsing this forum: No registered users and 3 guests