Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by PrzemoF »

I recompiled locally spacenavd and libspnav using fedora rpm build system. Both packages should be identical to what I had installed before on my system as fedora leaves all options as they are by default. Yet, after reinstalling them from the local build FrreCAD log shows:

Code: Select all

Log: Connected to spacenav daemon
the spaceball options in FreeCAD are active (no buttons detected), but spaceball doesn't work. Also my test case in python no longer dies with connection problem.

Edit:
Linuxbox restarted and .Xauthority copy removed from /root (just in case) - it's still the same.
FreeCAD connects to spacenavd, but no buttons and doesn't work.
spacenavd configuration tool (spnavcfg) reports daemon is not running! So FreeCAD reports connection even when the daemon is not running (TBC)?
Started spacenavd with:

Code: Select all

systemctl start spacenavd
confirmed with spnavcfg and:

Code: Select all

$ systemctl status spacenavd
● spacenavd.service - 3Dconnexion Input Devices Userspace Driver
   Loaded: loaded (/usr/lib/systemd/system/spacenavd.service; disabled; vendor preset: dis>
   Active: active (running) since Sat 2018-07-28 13:46:25 IST; 8s ago
  Process: 4724 ExecStart=/usr/bin/spacenavd (code=exited, status=0/SUCCESS)
 Main PID: 4726 (spacenavd)
    Tasks: 1 (limit: 4915)
   Memory: 344.0K
   CGroup: /system.slice/spacenavd.service
           └─4726 /usr/bin/spacenavd

lip 28 13:46:25 fedora systemd[1]: Starting 3Dconnexion Input Devices Userspace Driver...
lip 28 13:46:25 fedora systemd[1]: Started 3Dconnexion Input Devices Userspace Driver.
P.S. I'm sorry for a chaotic style, but there are still too many loose ends to make sense of it.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by PrzemoF »

albert.emil wrote: Sun Jul 15, 2018 6:16 am [..]
Running both the AppImage of 0.17 as well as the nightly version of 0.18_pre from copr as root by calling
[..] SpaceNavigator still not available.
The nightlies are compiled without spnav support. From build log:

Code: Select all

Could NOT find Spnav (missing: SPNAV_LIBRARY SPNAV_INCLUDE_DIR) 
I hope to get it fixed with this [1]

[1] https://github.com/FreeCAD/FreeCAD/pull ... 612e16fb6c

Edit: Werner (thanks!!) just merged my PR, so the next nightly will have spnav support:

Code: Select all

-- Found Spnav: /usr/lib64/libspnav.so
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by PrzemoF »

@albert.emil : the latest nightly is compiled with spnav support. Please test whenever you have a chance. It doesn't work for me, but it's a step forward as the options are visible now.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by PrzemoF »

I don't fully understand the issue yet, so please be careful ;)
Looks like the old x11 way doesn't work anymore - see here [1]. I tweaked cube code from libspnav examples to know exactly why it cannot connect and libspnav fails here (file spnav.c):

Code: Select all

int spnav_x11_open(Display *display, Window win)
{
        if(IS_OPEN) {
                return -1;
        }

        dpy = display;

        motion_event = XInternAtom(dpy, "MotionEvent", True);
        button_press_event = XInternAtom(dpy, "ButtonPressEvent", True);
        button_release_event = XInternAtom(dpy, "ButtonReleaseEvent", True);
        command_event = XInternAtom(dpy, "CommandEvent", True);

        if(!motion_event || !button_press_event || !button_release_event || !command_event) {
                dpy = 0;
                return -1;      /* daemon not started */ <-- FAILS here despite the daemon running OK
        }
[..]
simple_x11 from libspnav examples doesn't work (it uses spnav_x11_open), but simple_af_unix (uses spnav_open) works fine:

Code: Select all

$ ./simple_x11
failed to connect to the space navigator daemon

$ ./simple_af_unix
got motion event: t(0, -29, 60) r(67, 14, -22)
got motion event: t(0, -29, 60) r(46, 14, -22)
got motion event: t(0, -41, 122) r(46, 14, -22)
got motion event: t(0, -41, 122) r(70, 65, 77)
got motion event: t(0, -76, 217) r(70, 65, 77)
got motion event: t(0, -76, 217) r(71, 119, 80)
I don't know (yet) exactly how FreeCAD uses spnav events, but that seems to be the problem that we need to solve.

[1] https://stackoverflow.com/questions/465 ... with-linux
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by wmayer »

albert.emil wrote:Despite Blender using a socket connection to spacenavd (which is working), FreeCAD uses the X11-bindings.
Since it was said that the space navigator works with Blender I wonder whether we should do it the same way, then.
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by tanderson69 »

wmayer wrote: Sun Jul 29, 2018 8:20 am
albert.emil wrote:Despite Blender using a socket connection to spacenavd (which is working), FreeCAD uses the X11-bindings.
Since it was said that the space navigator works with Blender I wonder whether we should do it the same way, then.
Probably. I think the change would be simple, just a matter of changing 'spnav_x11_open' to 'spnav_open'. There is a small chance that you could loose support for old serial models(see below), but I think I am the only one that has been using the old devices and you don't have to worry about me.

Just some history: When I added linux spaceball support for freecad, spacenav didn't have any support for the old serial models and the proprietary driver still worked* and did support the old devices. The x11 protocol was supported by both the proprietary driver and spacenav, so that seemed like the best choice for the broadest support of devices. I didn't foresee the headaches that x11 has brought.


*proprietary driver still might work. You could still download it the last time I checked the website, about 2 years ago.
wmayer
Founder
Posts: 20324
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by wmayer »

Probably. I think the change would be simple, just a matter of changing 'spnav_x11_open' to 'spnav_open'. There is a small chance that you could loose support for old serial models(see below), but I think I am the only one that has been using the old devices and you don't have to worry about me.
If this change is really so trivial as you say then it should be no problem to add an option to either use 'spnav_x11_open' or 'spnav_open' so that serial devices are still supported.
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by tanderson69 »

wmayer wrote: Sun Jul 29, 2018 3:06 pm If this change is really so trivial as you say then it should be no problem to add an option to either use 'spnav_x11_open' or 'spnav_open' so that serial devices are still supported.
Yes.
User avatar
PrzemoF
Veteran
Posts: 3520
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by PrzemoF »

I think it's not that easy. I did the swap - doesn't work. Maybe we could use spnav_poll_event instead of spnav_x11_event? They are not 1 to 1 replacements. Reference link [1, page 7].

[1] https://media.readthedocs.org/pdf/spnav ... /spnav.pdf
User avatar
tanderson69
Veteran
Posts: 1626
Joined: Thu Feb 18, 2010 1:07 am

Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28

Post by tanderson69 »

PrzemoF wrote: Sun Jul 29, 2018 6:56 pm I think it's not that easy. I did the swap - doesn't work. Maybe we could use spnav_poll_event instead of spnav_x11_event? They are not 1 to 1 replacements. Reference link [1, page 7].

[1] https://media.readthedocs.org/pdf/spnav ... /spnav.pdf
You're right. I forgot about the whole 'x11EventFilter override' thing. Sorry, I should stop spouting off from 8 year old memories.
Post Reply