Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
Forum rules
and Helpful information
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!
Also, be nice to others! Read the FreeCAD code of conduct!
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
Yes, I bought a basic SpaceNavigator a couple years ago (using some of that money from Aleph Objects - thanks again!).
When I was starting the recent work, I made a couple test programs with the sockets API and with the X11 one - both seem to work fine with the gear I have (USB SpaceNavigator, Ubuntu 18.04, Qt5.11). The main difference is that the socket API is polled, where the X one is event driven. So, I didn't have a good reason to prefer one over the other, and it sounds like the socket API might not support some older devices.
I'd be glad to implement the sockets API if there's a reason to, however the code around there is already getting a bit unwieldy with precompiler options. Would it be OK, to only do the SpaceNavigator sockets API for Qt5?
When I was starting the recent work, I made a couple test programs with the sockets API and with the X11 one - both seem to work fine with the gear I have (USB SpaceNavigator, Ubuntu 18.04, Qt5.11). The main difference is that the socket API is polled, where the X one is event driven. So, I didn't have a good reason to prefer one over the other, and it sounds like the socket API might not support some older devices.
I'd be glad to implement the sockets API if there's a reason to, however the code around there is already getting a bit unwieldy with precompiler options. Would it be OK, to only do the SpaceNavigator sockets API for Qt5?
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
There was the request by @freecad-heini-1 (https://forum.freecadweb.org/viewtopic. ... 90#p256492) to do it the same as Blender as this seems to work flawlessly. After logging in and starting Blender you can simply use the device while for FreeCAD you still have to run these steps every time:When I was starting the recent work, I made a couple test programs with the sockets API and with the X11 one - both seem to work fine with the gear I have (USB SpaceNavigator, Ubuntu 18.04, Qt5.11). The main difference is that the socket API is polled, where the X one is event driven.
Code: Select all
sudo /etc/init.d/spacenavd stop
sudo xhost +
sudo /etc/init.d/spacenavd start
Yes, tanderson69 mentioned this above that it can happen that his serial device won't work this way any more. But therefore it would be good to keep the X-server approach and add e.g. a cmake option for it.So, I didn't have a good reason to prefer one over the other, and it sounds like the socket API might not support some older devices.
Only supporting Qt5 shouldn't be a problem as this is the default for most recent releases of the major distributions. Also, feel free to put the code into its own source files as currently it looks a bit messy due to the heavy use of #ifdef's.I'd be glad to implement the sockets API if there's a reason to, however the code around there is already getting a bit unwieldy with precompiler options. Would it be OK, to only do the SpaceNavigator sockets API for Qt5?
Thanks in advance!
P.S.: As a reference here is the link to the Blender code that uses the polling API of spacenav:
https://github.com/UPBGE/blender/blob/m ... erUnix.cpp
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
Hi,
I put together a solution for the socket interface. It can be found here:
https://github.com/tsadowski/FreeCAD/tree/LinuxSpacenav
It works for my on Arch Linux under Gnome/Wayland with XWayland. I don't want to make a pull request yet because I would like to find a solution for serial devices as well using the inputattach method as described here:
https://wiki.archlinux.org/index.php/Se ... rnel_input
and here:
https://www.kernel.org/doc/Documentatio ... ystick.txt
Unluckily even though the inputattach works, jstest remains silent. It might just be the crappy pl2303 usb to serial adapter which possibly does not support RTS/CTS. Maybe a FTDI chip could work.
Cheers,
Torsten
I put together a solution for the socket interface. It can be found here:
https://github.com/tsadowski/FreeCAD/tree/LinuxSpacenav
It works for my on Arch Linux under Gnome/Wayland with XWayland. I don't want to make a pull request yet because I would like to find a solution for serial devices as well using the inputattach method as described here:
https://wiki.archlinux.org/index.php/Se ... rnel_input
and here:
https://www.kernel.org/doc/Documentatio ... ystick.txt
Unluckily even though the inputattach works, jstest remains silent. It might just be the crappy pl2303 usb to serial adapter which possibly does not support RTS/CTS. Maybe a FTDI chip could work.
Cheers,
Torsten
Last edited by tsadowski on Wed Oct 17, 2018 10:03 pm, edited 1 time in total.
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
Thanks Torsten, and sorry it's taken me so long to (still not) do anything about this. For what it's worth, in general, it's a good idea to communicate about work that you're thinking about doing, when there's a chance someone else will already be doing that work. Otherwise, there is a real risk of duplicating (read: wasting) effort, which is our most precious resource.
From your commit message, I'm assuming that the X11 input stuff is incompatible with Wayland, is that right? If so, it would seem that's a good reason to look at switching to the new polling API from the event-based one, like you've done here.
From your commit message, I'm assuming that the X11 input stuff is incompatible with Wayland, is that right? If so, it would seem that's a good reason to look at switching to the new polling API from the event-based one, like you've done here.
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
IMO, the old X11-event based code should not be removed but a CMake option should be provided so that people who build their own FreeCAD still can switch back to the X11 method in case the polling method doesn't work.
And to avoid an ifdef/else/endif mess and thus to keep maintenance low I suggest to have one class the uses the X11 API of spacenav and in another class (it can be the same class name if guarded by an ifdef/else/endif) using the polling API.
And to avoid an ifdef/else/endif mess and thus to keep maintenance low I suggest to have one class the uses the X11 API of spacenav and in another class (it can be the same class name if guarded by an ifdef/else/endif) using the polling API.
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
@ian You are of course right about communicating but I had some time and because it simply worked, I posted the result.
The drivers under Wayland cannot use X because XWayland is just a layer for the running programs. We have to switch as Wayland will become more common.
@wmayer I will try to cleanup the #ifdef tangle and add the X11 API back afterwards with an SPNAV_USE_X11 option for cmake.
Does anyone know, why SpaceNavigatorDevice.cpp does also open the spacenav driver?
Cheers,Torsten
The drivers under Wayland cannot use X because XWayland is just a layer for the running programs. We have to switch as Wayland will become more common.
@wmayer I will try to cleanup the #ifdef tangle and add the X11 API back afterwards with an SPNAV_USE_X11 option for cmake.
Does anyone know, why SpaceNavigatorDevice.cpp does also open the spacenav driver?
Cheers,Torsten
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
You can ignore this class. It's the implementation of the Coin3d developers who also implemented the original Quarter library but inside FreeCAD we don't use it. Instead we handle the space mouse support in our own class (GUIApplicationNativeEventAware).Does anyone know, why SpaceNavigatorDevice.cpp does also open the spacenav driver?
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
You mean this [1]?
Code: Select all
PRIVATE(this)->hasdevice =
spnav_x11_open(QX11Info::display(), PRIVATE(this)->windowid) == -1 ? false : true;
[1] https://github.com/FreeCAD/FreeCAD/blob ... ce.cpp#L94spnav.spnav_x11_open(display,window)
Opens a connection to the daemon, using the original magellan X11 protocol. Any application using this protocol should be compatible with the proprietary 3D connexion driver too.
[2] https://media.readthedocs.org/pdf/spnav ... /spnav.pdf
[3] http://spacemice.org/pdf/Magellan_Protocol.pdf
P.S. I'm just guessing....
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
No worries - was more suggesting that it would've been fine to drop me an email/pm. I had already done much of the same work, so could've shared that directly.
It might be good to make the new cmake option less SPNAV-specific, as there could be other Wayland/X11 differences around. Hopefully not, since we're pretty good about sticking to Qt for GUI interaction, but there's not much penalty for making the variable USE_WAYLAND instead, even if it only applies to Space Navigator for now.
Re: Unable to connect to SpaceNavigator with FreeCAD 0.17 on Fedora 28
Hi,
I just pushed a first version to my Github repository. The Linux build works with Qt5. I will also try to build on Linux with Qt4 and on Mac OSX. I would appreciate, if someone could work on the Windows build.
I kept the option name SPNAV_USE_X11. The option has nothing to do with Wayland directly and the polling driver works under both window systems.
Cheers,
Torsten
I just pushed a first version to my Github repository. The Linux build works with Qt5. I will also try to build on Linux with Qt4 and on Mac OSX. I would appreciate, if someone could work on the Windows build.
I kept the option name SPNAV_USE_X11. The option has nothing to do with Wayland directly and the polling driver works under both window systems.
Cheers,
Torsten