
#include <Spectre/System/MessageHandler.h>
#include <Spectre/System/Log.h>
#include "EventsExample.h"

void EventsExample::init()
{
	getMessageHandler()->registerListener(this);
}

void EventsExample::onEvent(const sp::Event& event)
{
	if (event.type == sp::Event::Key) {
		std::string name = event.key.getKeyName();
		const char* pressed = event.key.pressed ? "pressed" : "released";
		sp::Log::info("Key: %s %s", name.c_str(), pressed);
	}

	if (event.type == sp::Event::MouseButton) {
		std::string name = event.mouseButton.getName();
		const char* pressed = event.mouseButton.pressed ? "pressed" : "released";
		sp::Log::info("MouseButton: %s %s", name.c_str(), pressed);
	}
}

void EventsExample::update(double dt)
{
	// Nothing to do
}

void EventsExample::render()
{
	// Nothing to do
}
