Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qt6 integration of 3dconnexion spacemouse devices
Forum Updated to NodeBB v4.3 + New Features

Qt6 integration of 3dconnexion spacemouse devices

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
4 Posts 4 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LTartarini
    wrote on last edited by
    #1

    Hello everyone, hope this finds you well.

    I have been wondering if there are any updates regarding qt integration of the spacemouse sdk.

    I found this old post https://forum.3dconnexion.com/viewtopic.php?f=19&t=4968 but all the source code files are not present anymore and I don't think I'm skilled enough to rewrite it given the information present in the forum (here's the updated link to the post https://www.codegardening.com/post/2011/2011-02-05-using-the-3dconnexion-mouse-with-a-qt-application/) and honestly it looks strange to me that Qt has not yet made any integration packages for 3d connexion devices.

    I have tried the basic windows way using window handlers but I can't make it work (no input read) as soon as I pass the handler to the qMainWindow as HWND(mainWindow.winId()), while it works fine if I create a dedicated window to read the data.

    Could you please give me some suggestions or point me to some resources?

    InTheBeningingI 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should use the way back machine to access the archived version of that page.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • L LTartarini

        Hello everyone, hope this finds you well.

        I have been wondering if there are any updates regarding qt integration of the spacemouse sdk.

        I found this old post https://forum.3dconnexion.com/viewtopic.php?f=19&t=4968 but all the source code files are not present anymore and I don't think I'm skilled enough to rewrite it given the information present in the forum (here's the updated link to the post https://www.codegardening.com/post/2011/2011-02-05-using-the-3dconnexion-mouse-with-a-qt-application/) and honestly it looks strange to me that Qt has not yet made any integration packages for 3d connexion devices.

        I have tried the basic windows way using window handlers but I can't make it work (no input read) as soon as I pass the handler to the qMainWindow as HWND(mainWindow.winId()), while it works fine if I create a dedicated window to read the data.

        Could you please give me some suggestions or point me to some resources?

        InTheBeningingI Offline
        InTheBeningingI Offline
        InTheBeninging
        wrote on last edited by InTheBeninging
        #3

        @LTartarini I used the same example zip file and only had to tweak a little bit to make it run on Qt 5.15.2.

        First they split up QObject::setEventFilter into setEventFilter and setNativeEventFilter. We need the latter one. This requires making the Mouse3DInput class a subclass of QAbstractNativeEventFilter

        class Mouse3DInput : public QObject, public QAbstractNativeEventFilter { ... }
        

        Now we have to move the implementation of the original bool Mouse3DInput::RawInputEventFilter(void* msg, long* result) function into the definition of the QAbstractNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override.

        class Mouse3DInput : public QObject, public QAbstractNativeEventFilter {
            Q_OBJECT
        public:
            Mouse3DInput(QWidget* widget);
            ~Mouse3DInput();
            //we have to make it non static and public to match the virtual function
            bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override; 
            ...
        }
        
        //Mouse3DInput.cpp
        bool Mouse3DInput::nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
            if (gMouseInput == 0)
                return false;
            MSG* msg = (MSG*)(message);
            if (msg->message == WM_INPUT) {
                HRAWINPUT hRawInput = reinterpret_cast<HRAWINPUT>(msg->lParam);
        	gMouseInput->OnRawInput(RIM_INPUT,hRawInput);
        	if (result != 0)
        		result = 0;
        	return true;
            }
            return false;
        }
        

        In the constructor we can use our new filter.

        Mouse3DInput::Mouse3DInput(QWidget* widget) : QObject(widget) {
            fLast3dmouseInputTime = 0;
            InitializeRawInput((HWND)widget->winId());
            gMouseInput = this;
            qApp->installNativeEventFilter(this);
        }
        
        1 Reply Last reply
        0
        • B Offline
          B Offline
          Benny36
          wrote on last edited by
          #4

          Hey, that sounds awsome! Could you explain which files you edited or even share your files for Qt 5.15.2 ?
          Sorry, I´m just a user of 3D Software and would really enjoy working with the spacemouse in my Qt apps.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved