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;
}