package speiger.src.coreengine;

import org.lwjgl.glfw.GLFW;

import speiger.src.coreengine.rendering.input.devices.FileDrop;
import speiger.src.coreengine.rendering.input.devices.Joystick;
import speiger.src.coreengine.rendering.input.devices.Keyboard;
import speiger.src.coreengine.rendering.input.devices.Mouse;
import speiger.src.coreengine.rendering.input.window.Window;
import speiger.src.coreengine.rendering.input.window.WindowManager;
import speiger.src.coreengine.utils.eventbus.EventBus;

public class NewInputTest {
	
	EventBus bus = new EventBus();
	WindowManager manager = new WindowManager();
	
	public static void main(String[] args) {
		new NewInputTest().run();
	}
	
	public void run() {
		GLFW.glfwInit();
		manager.initialize();
		Mouse.INSTANCE.init(bus);
		Keyboard.INSTANCE.init(bus);
		Joystick.INSTANCE.init(manager, bus);
		FileDrop.INSTANCE.init(bus);
		manager.addDevices(Mouse.INSTANCE, Keyboard.INSTANCE, Joystick.INSTANCE, FileDrop.INSTANCE);
		Window window = manager.builder().title("Testing Engine").build();
		window.visible(true);
		while(!window.shouldClose()) {
			GLFW.glfwPollEvents();
			window.beginFrame();
			window.handleInput();
			window.finishFrame();
			try { Thread.sleep(100); }
			catch(InterruptedException e) { e.printStackTrace(); }
		}
		window.destroy();
		manager.destroy();
	}
}
