Esempio n. 1
0
void InputHandler::update() {
	SDL_Event evt;
	onMouseButtonUp();
	while (SDL_PollEvent(&evt)) {
		switch (evt.type) {
		case SDL_QUIT:
			TheGame::Instance()->quit();
			break;
		case SDL_MOUSEMOTION:
			onMouseMove(evt);
			break;
		case SDL_MOUSEBUTTONDOWN:
			onMouseButtonDown(evt);
			break;
		case SDL_MOUSEBUTTONUP:
			onMouseButtonUp();
			break;
		case SDL_KEYDOWN:
			onKeyDown();
			break;
		case SDL_KEYUP:
			onKeyUp();
			break;
		default:
			break;
		}
	}
}
void InputHandler::update()
{
	//SDL_Event event;

	if (event.type != SDL_MOUSEMOTION)
	{
		MouseMoved = false;
	}

	while (SDL_PollEvent(&event))
	{
		switch (event.type)
		{
		case SDL_QUIT:
			TheGame::Instance()->quit();
			break;

		case SDL_JOYAXISMOTION:
			onJoystickAxisMove(event);
			break;

		case SDL_JOYBUTTONDOWN:
			onJoystickButtonDown(event);
			break;

		case SDL_JOYBUTTONUP:
			onJoystickButtonUp(event);
			break;

		case SDL_MOUSEMOTION:
			MouseMoved = true;
			onMouseMove(event);
			break;

		case SDL_MOUSEBUTTONDOWN:
			onMouseButtonDown(event);
			break;

		case SDL_MOUSEBUTTONUP:
			onMouseButtonUp(event);
			break;

		case SDL_KEYDOWN:
			onKeyDown();
			break;

		case SDL_KEYUP:
			onKeyUp();
			break;

		default:
			break;
		}
	}
}
void InputHandler::update()
{
	SDL_Event event;

	while (SDL_PollEvent(&event))
	{
		switch (event.type)
		{
		case SDL_QUIT:
			Game::getInstance()->clean();
			break;

		case SDL_JOYAXISMOTION:
			onJoystickAxisMove(event);
			break;

		case SDL_JOYBUTTONDOWN:
			onJoystickButtonDown(event);
			break;

		case SDL_JOYBUTTONUP:
			onJoystickButtonUp(event);
			break;

		case SDL_MOUSEMOTION:
			onMouseMove(event);
			break;

		case SDL_MOUSEBUTTONDOWN:
			onMouseButtonDown(event);
			break;

		case SDL_MOUSEBUTTONUP:
			onMouseButtonUp(event);
			break;

		case SDL_KEYDOWN:
			onKeyDown();
			break;

		case SDL_KEYUP:
			onKeyUp();
			break;

		default:
			break;
		}

	}
}
void ManejadorEntrada::actualizar()
{
    SDL_Event evento;
    while(SDL_PollEvent(&evento))
    {
        switch (evento.type)
        {
            case SDL_QUIT:
                ElJuego::Instancia()->salir();
                break;

            case SDL_JOYAXISMOTION:
                onJoystickAxisMove(evento);
                break;

            case SDL_JOYBUTTONDOWN:
                onJoystickButtonDown(evento);
                break;

            case SDL_JOYBUTTONUP:
                onJoystickButtonUp(evento);
                break;

            case SDL_MOUSEMOTION:
                onMouseMove(evento);
                break;

            case SDL_MOUSEBUTTONDOWN:
                onMouseButtonDown(evento);
                break;

            case SDL_MOUSEBUTTONUP:
                onMouseButtonUp(evento);
                break;

            case SDL_KEYDOWN:
                onKeyDown();
                break;

            case SDL_KEYUP:
                onKeyUp();
                break;

            default:
                break;
        }
    }
}
void mouseFunc(int button, int state, int x, int y)
{
#if 0 
    if (state)
        mgr->mouseButtonRelease(button, x, y);
    else
        mgr->mouseButtonPress(button, x, y);
#endif

    // redirect the message to the viewer instance
    if(state == GLUT_DOWN)
    {
        onMouseButtonDown(button, x, Height - y - 1);
    }
    else if(state == GLUT_UP)
    {
        onMouseButtonUp(button, x, Height - y - 1);
    }
}
Esempio n. 6
0
void InputHandler::update()
{
    SDL_Event event;
    m_keyStates = (Uint8*)SDL_GetKeyboardState(0);
    while(SDL_PollEvent(&event)){
        switch (event.type) {
            case SDL_QUIT:
                TheGame::Instance() -> quit();
                break;
            case SDL_JOYAXISMOTION:
                onJoystickAxisMove(event);
                break;
            case SDL_JOYBUTTONDOWN:
                onJoystickButtonDown(event);
                break;
            case SDL_JOYBUTTONUP:
                onJoystickButtonUp(event);
                break;
            case SDL_MOUSEMOTION:
                onMouseMove(event);
                break;
            case SDL_MOUSEBUTTONDOWN:
                onMouseButtonDown(event);
                break;
            case SDL_MOUSEBUTTONUP:
                onMouseButtonUp(event);
                break;
            case SDL_KEYDOWN:
                onKeyDown(event.key.keysym.scancode);
                break;
            case SDL_KEYUP:
                onKeyUp(event.key.keysym.scancode);
                break;
            default:
                break;
        }


    }

}
Esempio n. 7
0
void InputHandler::Update()
{
	SDL_Event event;
	mKeyState = SDL_GetKeyboardState(0);
	while(SDL_PollEvent(&event))
	{
		if(event.type == SDL_QUIT)
		{
			Engine::Instance()->Shutdown();
		}

#pragma region Joystick
		if(event.type == SDL_JOYAXISMOTION)
		{
			int whichOne = event.jaxis.which;

			//Left Stick move Left or right
			if(event.jaxis.axis == 0)
			{
				if(event.jaxis.value > mJoystickDeadZone)
					mJoystickValues[whichOne].first->setX(1);
				
				else if(event.jaxis.value < -mJoystickDeadZone)
					mJoystickValues[whichOne].first->setX(-1);
				
				else
					mJoystickValues[whichOne].first->setX(0);
			}

			//Right Stick moves Right or Left
			if(event.jaxis.axis == 1)
			{
				if(event.jaxis.value > mJoystickDeadZone)
					mJoystickValues[whichOne].first->setY(1);
				
				else if(event.jaxis.value < -mJoystickDeadZone)
					mJoystickValues[whichOne].first->setY(-1);
				
				else
					mJoystickValues[whichOne].first->setY(0);
			}

			if(event.jaxis.axis == 3)
			{
				if(event.jaxis.value > mJoystickDeadZone)
					mJoystickValues[whichOne].second->setX(1);
				
				else if(event.jaxis.value < -mJoystickDeadZone)
					mJoystickValues[whichOne].second->setX(-1);
				
				else
					mJoystickValues[whichOne].second->setX(0);
			}

			if(event.jaxis.axis == 4)
			{
				if(event.jaxis.value > mJoystickDeadZone)
					mJoystickValues[whichOne].second->setY(1);
				
				else if(event.jaxis.value < -mJoystickDeadZone)
					mJoystickValues[whichOne].second->setY(-1);
				
				else
					mJoystickValues[whichOne].second->setY(0);
			}
		}
#pragma endregion

#pragma region Mouse

		if(event.type == SDL_MOUSEMOTION)
		{
			mMousePosition->setX(event.motion.x);
			mMousePosition->setY(event.motion.y);
		}

		switch(event.type)
		{
			case SDL_MOUSEBUTTONDOWN:
				onMouseButtonDown(event);
				break;

			case SDL_MOUSEBUTTONUP:
				onMouseButtonUp(event);
				break;

			default:
				break;
		}
#pragma endregion
	}
}