int inputManager::update(void)
{
SDL_Event currentEvent;

	while ( !messageP.empty() )
	{
		AssetManager::lockMutex( inputManager::mutex_event );
		currentEvent = messageP.receiveMessage();
		AssetManager::unlockMutex( inputManager::mutex_event );

		if (currentEvent.type == SDL_ACTIVEEVENT)
		{
			if ( currentEvent.active.state & SDL_APPINPUTFOCUS )
			{
				if (currentEvent.active.gain==0)
				{
					active = false;
					SDL_WM_GrabInput(SDL_GRAB_OFF);
					SDL_ShowCursor(SDL_ENABLE);
				}
				else
				{
					active = true;
					SDL_ShowCursor(SDL_DISABLE);
					SDL_WM_GrabInput(SDL_GRAB_ON);
				}
			}
		}

		if (active)
		{
			switch (currentEvent.type)
			{
			case SDL_KEYDOWN:
			case SDL_KEYUP:
				keyPress(currentEvent);
				break;
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
				mousePress(currentEvent);
				break;
			case SDL_MOUSEMOTION:
				mouseMotion(currentEvent);
				break;
			default:
				break;
			}
		}
	}

	return 0;
}
Esempio n. 2
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
}
Esempio n. 3
0
EventHandler::EventHandler( Proxy* proxy )
    : _proxy( proxy )
{
    LBASSERT( proxy );

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

    Pipe* pipe = proxy->getChannel().getPipe();
    MessagePump* messagePump = pipe->isThreaded() ? pipe->getMessagePump() :
                                            pipe->getConfig()->getMessagePump();
    if( messagePump )
        messagePump->register_( proxy );
    else
        LBINFO << "Using deflect::EventHandler without MessagePump, "
               << "external event dispatch assumed" << std::endl;
}
Esempio n. 4
0
EventHandler::~EventHandler()
{
    Pipe* pipe = _proxy->getChannel().getPipe();
    MessagePump* messagePump =
        dynamic_cast<MessagePump*>( pipe->isThreaded() ?
                                    pipe->getMessagePump() :
                                    pipe->getConfig()->getMessagePump( ));
    if( messagePump )
        messagePump->deregister( _proxy );

    EventHandlers::iterator i = lunchbox::find( *_eventHandlers, this );
    LBASSERT( i != _eventHandlers->end( ));
    _eventHandlers->erase( i );
    if( _eventHandlers->empty( ))
    {
        delete _eventHandlers.get();
        _eventHandlers = 0;
    }
}
Esempio n. 5
0
EventHandler::~EventHandler()
{
    eq::Pipe* pipe = _window->getPipe();
    MessagePump* messagePump = dynamic_cast<MessagePump*>( pipe->isThreaded() ?
                 pipe->getMessagePump() : pipe->getConfig()->getMessagePump( ));
    if( messagePump )
    {
        Display* display = _window->getXDisplay();
        LBASSERT( display );
        messagePump->deregister( display );
    }

    EventHandlers::iterator i = stde::find( *_eventHandlers, this );
    LBASSERT( i != _eventHandlers->end( ));
    _eventHandlers->erase( i );
    if( _eventHandlers->empty( ))
    {
        delete _eventHandlers.get();
        _eventHandlers = 0;
    }
}
Esempio n. 6
0
EventHandler::~EventHandler()
{
    if( _magellanUsed )
    {
#ifdef EQUALIZER_USE_MAGELLAN_GLX
        lunchbox::ScopedFastWrite mutex( _magellan );
        if( --_magellan->used == 0 )
        {
            if( spnav_close() == -1 )
            {
                LBWARN
                    << "Couldn't close connection to the space navigator daemon"
                    << std::endl;
            }
        }
#endif
        _magellanUsed = false;
    }

    eq::Pipe* pipe = _window->getPipe();
    MessagePump* messagePump =
        dynamic_cast<MessagePump*>( pipe->isThreaded() ?
                                    pipe->getMessagePump() :
                                    pipe->getConfig()->getMessagePump( ));
    if( messagePump )
    {
        Display* display = _window->getXDisplay();
        LBASSERT( display );
        messagePump->deregister( display );
    }

    EventHandlers::iterator i = stde::find( *_eventHandlers, this );
    LBASSERT( i != _eventHandlers->end( ));
    _eventHandlers->erase( i );
    if( _eventHandlers->empty( ))
    {
        delete _eventHandlers.get();
        _eventHandlers = 0;
    }
}
Esempio n. 7
0
void Pipe::_setupCommandQueue()
{
    LBINFO << "Set up pipe message pump for " << _impl->windowSystem
           << std::endl;

    Config* config = getConfig();
    config->setupMessagePump( this );

    if( !_impl->thread ) // Non-threaded pipes have no pipe thread message pump
        return;

    CommandQueue* queue = _impl->thread->getWorkerQueue();
    LBASSERT( queue );
    LBASSERT( !queue->getMessagePump( ));

    Global::enterCarbon();
    MessagePump* pump = createMessagePump();
    if( pump )
        pump->dispatchAll(); // initializes _impl->receiverQueue

    queue->setMessagePump( pump );
    Global::leaveCarbon();
}
Esempio n. 8
0
EventHandler::EventHandler( WindowIF* window )
        : _window( window )
{
    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( ));
    if( messagePump )
    {
        Display* display = window->getXDisplay();
        LBASSERT( display );
        messagePump->register_( display );
    }
    else
        LBINFO << "Using glx::EventHandler without glx::MessagePump, external "
               << "event dispatch assumed" << std::endl;
}