
#include <Spectre/Input/Keyboard.h>

namespace sp {

struct keyentry
{
	Keyboard::Key type;
	const char *name;
};

#define MapSym(key, name) { key, name }

struct keyentry table[] = {
	MapSym(Keyboard::Key::Unknown, "Unknown"),
	MapSym(Keyboard::Key::A, "A"),
	MapSym(Keyboard::Key::B, "B"),
	MapSym(Keyboard::Key::C, "C"),
	MapSym(Keyboard::Key::D, "D"),
	MapSym(Keyboard::Key::E, "E"),
	MapSym(Keyboard::Key::F, "F"),
	MapSym(Keyboard::Key::G, "G"),
	MapSym(Keyboard::Key::H, "H"),
	MapSym(Keyboard::Key::I, "I"),
	MapSym(Keyboard::Key::J, "J"),
	MapSym(Keyboard::Key::K, "K"),
	MapSym(Keyboard::Key::L, "L"),
	MapSym(Keyboard::Key::M, "M"),
	MapSym(Keyboard::Key::N, "N"),
	MapSym(Keyboard::Key::O, "O"),
	MapSym(Keyboard::Key::P, "P"),
	MapSym(Keyboard::Key::Q, "Q"),
	MapSym(Keyboard::Key::R, "R"),
	MapSym(Keyboard::Key::S, "S"),
	MapSym(Keyboard::Key::T, "T"),
	MapSym(Keyboard::Key::U, "U"),
	MapSym(Keyboard::Key::V, "V"),
	MapSym(Keyboard::Key::W, "W"),
	MapSym(Keyboard::Key::X, "X"),
	MapSym(Keyboard::Key::Y, "Y"),
	MapSym(Keyboard::Key::Z, "Z"),
	MapSym(Keyboard::Key::One, "1"),
	MapSym(Keyboard::Key::Two, "2"),
	MapSym(Keyboard::Key::Three, "3"),
	MapSym(Keyboard::Key::Four, "4"),
	MapSym(Keyboard::Key::Five, "5"),
	MapSym(Keyboard::Key::Six, "6"),
	MapSym(Keyboard::Key::Seven, "7"),
	MapSym(Keyboard::Key::Eight, "8"),
	MapSym(Keyboard::Key::Nine, "9"),
	MapSym(Keyboard::Key::Zero, "0"),
	MapSym(Keyboard::Key::Period, "Period"),
	MapSym(Keyboard::Key::Comma, "Comma"),
	MapSym(Keyboard::Key::Enter, "Enter"),
	MapSym(Keyboard::Key::Backspace, "Backspace"),
	MapSym(Keyboard::Key::Escape, "Escape"),
	MapSym(Keyboard::Key::Space, "Space"),
	MapSym(Keyboard::Key::Capslock, "Capslock"),
	MapSym(Keyboard::Key::Up, "Up"),
	MapSym(Keyboard::Key::Down, "Down"),
	MapSym(Keyboard::Key::Left, "Left"),
	MapSym(Keyboard::Key::Right, "Right"),

	// Numpad
	MapSym(Keyboard::Key::Numpad1, "Numpad 1"),
	MapSym(Keyboard::Key::Numpad2, "Numpad 2"),
	MapSym(Keyboard::Key::Numpad3, "Numpad 3"),
	MapSym(Keyboard::Key::Numpad4, "Numpad 4"),
	MapSym(Keyboard::Key::Numpad5, "Numpad 5"),
	MapSym(Keyboard::Key::Numpad6, "Numpad 6"),
	MapSym(Keyboard::Key::Numpad7, "Numpad 7"),
	MapSym(Keyboard::Key::Numpad8, "Numpad 8"),
	MapSym(Keyboard::Key::Numpad9, "Numpad 9"),
	MapSym(Keyboard::Key::Numpad0, "Numpad 0"),

	MapSym(Keyboard::Key::Home, "Home"),
	MapSym(Keyboard::Key::End, "End"),
	MapSym(Keyboard::Key::Insert, "Insert"),
	MapSym(Keyboard::Key::Delete, "Delete"),
	MapSym(Keyboard::Key::PageUp, "Page up"),
	MapSym(Keyboard::Key::PageDown, "Page down"),
	MapSym(Keyboard::Key::Pause, "Pause"),

	// Function keys.
	MapSym(Keyboard::Key::F1, "F1"),
	MapSym(Keyboard::Key::F2, "F2"),
	MapSym(Keyboard::Key::F3, "F3"),
	MapSym(Keyboard::Key::F4, "F4"),
	MapSym(Keyboard::Key::F5, "F5"),
	MapSym(Keyboard::Key::F6, "F6"),
	MapSym(Keyboard::Key::F7, "F7"),
	MapSym(Keyboard::Key::F8, "F8"),
	MapSym(Keyboard::Key::F9, "F9"),
	MapSym(Keyboard::Key::F10, "F10"),
	MapSym(Keyboard::Key::F11, "F11"),
	MapSym(Keyboard::Key::F12, "F12"),

	MapSym(Keyboard::Key::Tab, "Tab"),
	MapSym(Keyboard::Key::LShift, "Left Shift"),
	MapSym(Keyboard::Key::RShift, "Right Shift"),
	MapSym(Keyboard::Key::LCtrl, "Left Control"),
	MapSym(Keyboard::Key::RCtrl, "Right Control"),
	MapSym(Keyboard::Key::LAlt, "Left Alt"),
	MapSym(Keyboard::Key::RAlt, "Right Alt"),
};

std::string Keyboard::getKeyName(Key key)
{
	if (key >= Key::NUM_KEYS) {
		key = Key::Unknown;
	}
	return table[key].name;
}

} // namespace sp
