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?
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?
You mean this ?
Code: Select all
PRIVATE(this)->hasdevice = spnav_x11_open(QX11Info::display(), PRIVATE(this)->windowid) == -1 ? false : true;
 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.
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.