void Gui::GUIApplicationNativeEventAware::initSpaceball(QMainWindow *window)
{
    mainWindow = window;

#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

#ifdef _USE_3DCONNEXION_SDK
    spaceballPresent = Is3dmouseAttached();

    if (spaceballPresent) {
        fLast3dmouseInputTime = 0;

        if (InitializeRawInput(mainWindow->winId())) {
            gMouseInput = this;
            qApp->setEventFilter(Gui::GUIApplicationNativeEventAware::RawInputEventFilter);
        }
    }
#endif // _USE_3DCONNEXION_SDK

    Spaceball::MotionEvent::MotionEventType = QEvent::registerEventType();
    Spaceball::ButtonEvent::ButtonEventType = QEvent::registerEventType();
}
Exemplo n.º 2
0
void fgInitialiseSpaceball(void)
{
    if(sball_initialized != 0) {
        return;
    }

#if TARGET_HOST_POSIX_X11
    {
        Window w;

        if(!fgStructure.CurrentWindow)
        {
            sball_initialized = -1;
            return;
        }

        w = fgStructure.CurrentWindow->Window.Handle;
        if(spnav_x11_open(fgDisplay.Display, w) == -1)
        {
            sball_initialized = -1;
            return;
        }
    }
#endif

    sball_initialized = 1;
}
Exemplo n.º 3
0
int main(void)
{

#if defined(BUILD_X11)
	Display *dpy;
	Window win;
	unsigned long bpix;
#endif

	spnav_event sev;

	signal(SIGINT, sig);

#if defined(BUILD_X11)

	if(!(dpy = XOpenDisplay(0))) {
		fprintf(stderr, "failed to connect to the X server\n");
		return 1;
	}
	bpix = BlackPixel(dpy, DefaultScreen(dpy));
	win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1, 0, bpix, bpix);

	/* This actually registers our window with the driver for receiving
	 * motion/button events through the 3dxsrv-compatible X11 protocol.
	 */
	if(spnav_x11_open(dpy, win) == -1) {
		fprintf(stderr, "failed to connect to the space navigator daemon\n");
		return 1;
	}

#elif defined(BUILD_AF_UNIX)
	if(spnav_open()==-1) {
	  	fprintf(stderr, "failed to connect to the space navigator daemon\n");
		return 1;
	}
#else
#error Unknown build type!
#endif

	/* spnav_wait_event() and spnav_poll_event(), will silently ignore any non-spnav X11 events.
	 *
	 * If you need to handle other X11 events you will have to use a regular XNextEvent() loop,
	 * and pass any ClientMessage events to spnav_x11_event, which will return the event type or
	 * zero if it's not an spnav event (see spnav.h).
	 */
	while(spnav_wait_event(&sev)) {
		if(sev.type == SPNAV_EVENT_MOTION) {
			printf("got motion event: t(%d, %d, %d) ", sev.motion.x, sev.motion.y, sev.motion.z);
			printf("r(%d, %d, %d)\n", sev.motion.rx, sev.motion.ry, sev.motion.rz);
		} else {	/* SPNAV_EVENT_BUTTON */
			printf("got button %s event b(%d)\n", sev.button.press ? "press" : "release", sev.button.bnum);
		}
	}

	spnav_close();
	return 0;
}
Exemplo n.º 4
0
EventHandler::EventHandler( WindowIF* window )
        : _window( window )
        , _magellanUsed( false )
{
    LBASSERT( window );

    if( !_eventHandlers )
        _eventHandlers = new EventHandlers;
    _eventHandlers->push_back( this );

    eq::Pipe* pipe = window->getPipe();
    MessagePump* messagePump =
        dynamic_cast< MessagePump* >( pipe->isThreaded() ?
                                      pipe->getMessagePump() :
                                      pipe->getConfig()->getMessagePump( ));
    Display* display = window->getXDisplay();
    LBASSERT( display );
    if( messagePump )
        messagePump->register_( display );
    else
        LBINFO << "Using glx::EventHandler without glx::MessagePump, external "
               << "event dispatch assumed" << std::endl;

#ifdef EQUALIZER_USE_MAGELLAN_GLX
    lunchbox::ScopedFastWrite mutex( _magellan );
    if( !_magellan->display )
    {
        if( spnav_x11_open( display, window->getXDrawable( )) == -1 )
        {
            LBWARN << "Failed to connect to the space navigator daemon"
                   << std::endl;
            return;
        }
        _magellan->display = display;
    }
    else if( _magellan->display != display )
    {
        LBINFO << "Multi-display space mouse support incomplete" << std::endl;
        return;
    }
    else if( spnav_x11_window( window->getXDrawable( )) == -1 )
    {
        LBWARN << "Failed to register window with the space navigator daemon"
               << std::endl;
        return;
    }

    ++_magellan->used;
    _magellanUsed = true;
#endif
}
Exemplo n.º 5
0
void fgPlatformInitializeSpaceball(void)
{
    Window w;

    sball_initialized = 1;
    if(!fgStructure.CurrentWindow)
    {
        sball_initialized = -1;
        return;
    }

    w = fgStructure.CurrentWindow->Window.Handle;
    if(spnav_x11_open(fgDisplay.pDisplay.Display, w) == -1)
    {
        sball_initialized = -1;
        return;
    }
}
Exemplo n.º 6
0
EventHandler::EventHandler( WindowIF* window )
        : _window( window )
        , _magellanUsed( false )
{
    LBASSERT( window );

    if( !_eventHandlers )
        _eventHandlers = new EventHandlers;
    _eventHandlers->push_back( this );

#ifdef EQUALIZER_USE_MAGELLAN_GLX
    Display* display = window->getXDisplay();
    LBASSERT( display );
    lunchbox::ScopedFastWrite mutex( _magellan );
    if( !_magellan->display )
    {
        if( spnav_x11_open( display, window->getXDrawable( )) == -1 )
        {
            LBWARN << "Failed to connect to the space navigator daemon"
                   << std::endl;
            return;
        }
        _magellan->display = display;
    }
    else if( _magellan->display != display )
    {
        LBINFO << "Multi-display space mouse support incomplete" << std::endl;
        return;
    }
    else if( spnav_x11_window( window->getXDrawable( )) == -1 )
    {
        LBWARN << "Failed to register window with the space navigator daemon"
               << std::endl;
        return;
    }

    ++_magellan->used;
    _magellanUsed = true;
#endif
}
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();
}