#include "InputManager.h"
#include "EventKeyboard.h"
#include "WorldManager.h"
#include <Windows.h>

InputManager &InputManager::getInstance(){
	static InputManager InputM;
	return InputM;
}

bool InputManager::isValid(string event_name){
	if(event_name.compare("keyboard")==0&&event_name.compare("mouse")==0){
		return true;
	}
	return false;
}

/// Get terminal ready to capture input.
int InputManager::startUp(){
	return 0;
}

/// Revert back to normal terminal mode.
void InputManager::shutDown(){
}

/// Get input from the keyboard and mouse
/// For each object interested, pass event along.
void InputManager::getInput(){
	for(int i=0;i<256;i++){
		this->keys[i]=GetAsyncKeyState(i);
	}
	EventKeyboard kbd=EventKeyboard();
	kbd.setKey(this->keys);
  	WorldManager::getInstance().onEvent(&kbd);
}