void InputManager::getInput()
{
	int c = getch();

	if (c != ERR)
	{
		MEVENT m_event;
		if ((c == KEY_MOUSE) && (getmouse(&m_event) != ERR))
		{
			if (m_event.bstate & BUTTON1_CLICKED)
			{
				int y = m_event.y;
				int x = m_event.x;

				EventMouse m;

				m.setMouseY(y);
				m.setMouseX(x);
				m.setMouseAction(LEFT_BUTTON_CLICK);

				onEvent((Event*) &m);
			}

		}
		else
		{

			EventKeyboard k;
			k.setKey(c);

			onEvent((Event*) &k);
		}
	}
}
Esempio n. 2
0
void InputManager::getInput(){
    int key = getch();

    if(key != ERR){
        MEVENT m_event;
        if(key == KEY_MOUSE && getmouse(&m_event) == OK){
            if(m_event.bstate & BUTTON1_CLICKED){
                EventMouse* em = new EventMouse();
                em->setMouseAction(LEFT_BUTTON_CLICK);
                em->setMouseX(m_event.x);
                em->setMouseY(m_event.y);
                onEvent(em); 
            }
        }else{
            EventKeyboard* ek = new EventKeyboard();
            ek->setKey(key);
            onEvent(ek);
        }
    }   
}