Exemple #1
0
static int tdx_enable() {
  UInt16 clientID;

  if (InstallConnexionHandlers == NULL) {
    msgInfo << "No 3DConnexion driver on this system." << sendmsg;
    return -1;
  }
  OSErr result = InstallConnexionHandlers(tdx_msghandler, 0L, 0L);
  if (result != noErr) {
    msgInfo << "Unable to register with 3DConnexion driver." << sendmsg;
    return -1;
  }

#if 1
  // only respond to all events when we have focus
  clientID = RegisterConnexionClient(0, executablename,
               kConnexionClientModeTakeOver, kConnexionMaskAll);
#else
  // respond to all events whether we have focus or not
  clientID = RegisterConnexionClient(kConnexionClientWildcard, NULL,
               kConnexionClientModeTakeOver, kConnexionMaskAll);
#endif

  tdxevent.enabled = 1;
  tdxevent.client = clientID;

  return 0;
}
/* -------------------------------------------------------------------------- */
long ossimPlanetQtApplication::initInputDevices()
   // (UInt32 appID, 
//               Boolean showOnlyMyClientEvents, 
//               UInt16 mode, 
//               UInt32 mask)
{
   OSStatus err;
   gDevWrapperInfo.clientID = 0;
   gDevWrapperInfo.showClientEventsOnly = true;
   
//    gDevWrapperInfo.mainEventQueue = GetMainEventQueue();
   
   /* make sure the framework is installed */
   if (InstallConnexionHandlers == NULL)
   {
      ossimNotify(ossimNotifyLevel_WARN) << "3Dconnexion framework not found!\n" << std::endl;
//       fprintf(stderr, "3Dconnexion framework not found!\n");
      return -1;
   }
   
   /* install 3dx message handler in order to receive driver events */
   err = InstallConnexionHandlers(tdx_drv_handler, 0L, 0L);
//    assert(err == 0);
//    if (err)
//       return err;
   
   /* register our app with the driver */
//    gDevWrapperInfo.clientID = RegisterConnexionClient('osPt', (UInt8*)"ossimplanet", kConnexionClientModeTakeOver, kConnexionMaskAll);
   gDevWrapperInfo.clientID = RegisterConnexionClient('osPt', 0, kConnexionClientModeTakeOver, kConnexionMaskAll);
//    if (gDevWrapperInfo.clientID == 0)
//       return -2;
//    std::cout << "CLIENT ID = " <<    gDevWrapperInfo.clientID << std::endl;
//    fprintf(stderr, "3Dconnexion device initialized. Client ID: %d\n", 
   //gDevWrapperInfo.clientID);

   ossimPlanetAction(":iac tie axis0 LON").execute();
   ossimPlanetAction(":iac tie axis1 LAT").execute();
   ossimPlanetAction(":iac tie axis2 ZOOM").execute();
   ossimPlanetAction(":iac tie axis3 PITCH").execute();
//    ossimPlanetAction(":iac tie axis4 ROLL").execute();
   ossimPlanetAction(":iac tie axis5 YAW").execute();
   
   return err;
}
void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
{
    mainWindow = window;

#ifdef Q_WS_X11
#ifdef SPNAV_FOUND
    if (spnav_x11_open(QX11Info::display(), window->winId()) == -1)
        Base::Console().Log("Couldn't connect to spacenav daemon\n");
    else
    {
        Base::Console().Log("Connected to spacenav daemon\n");
        spaceballPresent = true;
    }
#endif
#endif

#ifdef _USE_3DCONNEXION_SDK
#ifdef Q_WS_WIN
    spaceballPresent = Is3dmouseAttached();

    if (spaceballPresent) {
        fLast3dmouseInputTime = 0;

        if (InitializeRawInput(mainWindow->winId())){
            gMouseInput = this;
            qApp->setEventFilter(Gui::GUIApplicationNativeEventAware::RawInputEventFilter);
        }
    }
#endif
//mac
#ifdef Q_WS_MACX
    OSStatus err;
    /* make sure the framework is installed */
    if (InstallConnexionHandlers == NULL)
      {
        Base::Console().Log("3Dconnexion framework not found!\n");
        return;
      }
    /* install 3dx message handler in order to receive driver events */
    err = InstallConnexionHandlers(tdx_drv_handler, 0L, 0L);
    assert(err == 0);
    if (err)
      {
        Base::Console().Log("Error installing 3Dconnexion handler\n");
        return;
      }
    /* register our app with the driver */
    //Pascal string Application name required to register driver for application
    UInt8  tdxAppName[] = {7,'F','r','e','e','C','A','D'};
    //32bit appID to register driver for application
    UInt32 tdxAppID = 'FCAd';
    //std::cerr << "tdxClientID: " << tdxClientID << std::endl;
    tdxClientID = RegisterConnexionClient(tdxAppID, tdxAppName, kConnexionClientModeTakeOver, kConnexionMaskAll);
    //std::cerr << "tdxClientID: " << tdxClientID << std::endl;
    if (tdxClientID == 0)
      {
        Base::Console().Log("Couldn't connect to 3Dconnexion driver\n");
        return;
      }
    
    Base::Console().Log("3Dconnexion device initialized. Client ID: %d\n", tdxClientID);
    spaceballPresent = true;
#endif
#endif // _USE_3DCONNEXION_SDK

    Spaceball::MotionEvent::MotionEventType = QEvent::registerEventType();
    Spaceball::ButtonEvent::ButtonEventType = QEvent::registerEventType();
}