
#include <Spectre/Input/Keyboard.h>

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

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

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

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

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

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

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