Browse Source

Added missing keys.

Branimir Karadžić 10 years ago
parent
commit
b854588861
3 changed files with 212 additions and 76 deletions
  1. 112 0
      examples/common/entry/entry.cpp
  2. 15 2
      examples/common/entry/entry.h
  3. 85 74
      examples/common/entry/entry_windows.cpp

+ 112 - 0
examples/common/entry/entry.cpp

@@ -38,6 +38,118 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 	}
 #endif // ENTRY_CONFIG_IMPLEMENT_DEFAULT_ALLOCATOR
 
+	static const char* s_keyName[] =
+	{
+		"None",
+		"Esc",
+		"Return",
+		"Tab",
+		"Space",
+		"Backspace",
+		"Up",
+		"Down",
+		"Left",
+		"Right",
+		"Insert",
+		"Delete",
+		"Home",
+		"End",
+		"PageUp",
+		"PageDown",
+		"Print",
+		"Plus",
+		"Minus",
+		"LeftBracket",
+		"RightBracket",
+		"Semicolon",
+		"Quote",
+		"Comma",
+		"Period",
+		"Slash",
+		"Backslash",
+		"Tilda",
+		"F1",
+		"F2",
+		"F3",
+		"F4",
+		"F5",
+		"F6",
+		"F7",
+		"F8",
+		"F9",
+		"F10",
+		"F11",
+		"F12",
+		"NumPad0",
+		"NumPad1",
+		"NumPad2",
+		"NumPad3",
+		"NumPad4",
+		"NumPad5",
+		"NumPad6",
+		"NumPad7",
+		"NumPad8",
+		"NumPad9",
+		"Key0",
+		"Key1",
+		"Key2",
+		"Key3",
+		"Key4",
+		"Key5",
+		"Key6",
+		"Key7",
+		"Key8",
+		"Key9",
+		"KeyA",
+		"KeyB",
+		"KeyC",
+		"KeyD",
+		"KeyE",
+		"KeyF",
+		"KeyG",
+		"KeyH",
+		"KeyI",
+		"KeyJ",
+		"KeyK",
+		"KeyL",
+		"KeyM",
+		"KeyN",
+		"KeyO",
+		"KeyP",
+		"KeyQ",
+		"KeyR",
+		"KeyS",
+		"KeyT",
+		"KeyU",
+		"KeyV",
+		"KeyW",
+		"KeyX",
+		"KeyY",
+		"KeyZ",
+		"GamepadA",
+		"GamepadB",
+		"GamepadX",
+		"GamepadY",
+		"GamepadThumbL",
+		"GamepadThumbR",
+		"GamepadShoulderL",
+		"GamepadShoulderR",
+		"GamepadUp",
+		"GamepadDown",
+		"GamepadLeft",
+		"GamepadRight",
+		"GamepadBack",
+		"GamepadStart",
+		"GamepadGuide",
+	};
+	BX_STATIC_ASSERT(Key::Count == BX_COUNTOF(s_keyName) );
+
+	const char* getName(Key::Enum _key)
+	{
+		BX_CHECK(_key < Key::Count, "Invalid key %d.", _key);
+		return s_keyName[_key];
+	}
+
 	char keyToAscii(Key::Enum _key, uint8_t _modifiers)
 	{
 		const bool isAscii = (Key::Key0 <= _key && _key <= Key::KeyZ)

+ 15 - 2
examples/common/entry/entry.h

@@ -84,13 +84,24 @@ namespace entry
 			Down,
 			Left,
 			Right,
-			PageUp,
-			PageDown,
+			Insert,
+			Delete,
 			Home,
 			End,
+			PageUp,
+			PageDown,
 			Print,
 			Plus,
 			Minus,
+			LeftBracket,
+			RightBracket,
+			Semicolon,
+			Quote,
+			Comma,
+			Period,
+			Slash,
+			Backslash,
+			Tilda,
 			F1,
 			F2,
 			F3,
@@ -170,6 +181,8 @@ namespace entry
 		};
 	};
 
+	const char* getName(Key::Enum _key);
+
 	struct MouseState
 	{
 		MouseState()

+ 85 - 74
examples/common/entry/entry_windows.cpp

@@ -332,80 +332,91 @@ namespace entry
 			, m_exit(false)
 		{
 			memset(s_translateKey, 0, sizeof(s_translateKey) );
-			s_translateKey[VK_ESCAPE]    = Key::Esc;
-			s_translateKey[VK_RETURN]    = Key::Return;
-			s_translateKey[VK_TAB]       = Key::Tab;
-			s_translateKey[VK_BACK]      = Key::Backspace;
-			s_translateKey[VK_SPACE]     = Key::Space;
-			s_translateKey[VK_UP]        = Key::Up;
-			s_translateKey[VK_DOWN]      = Key::Down;
-			s_translateKey[VK_LEFT]      = Key::Left;
-			s_translateKey[VK_RIGHT]     = Key::Right;
-			s_translateKey[VK_PRIOR]     = Key::PageUp;
-			s_translateKey[VK_NEXT]      = Key::PageUp;
-			s_translateKey[VK_HOME]      = Key::Home;
-			s_translateKey[VK_END]       = Key::End;
-			s_translateKey[VK_SNAPSHOT]  = Key::Print;
-			s_translateKey[VK_OEM_PLUS]  = Key::Plus;
-			s_translateKey[VK_OEM_MINUS] = Key::Minus;
-			s_translateKey[VK_F1]        = Key::F1;
-			s_translateKey[VK_F2]        = Key::F2;
-			s_translateKey[VK_F3]        = Key::F3;
-			s_translateKey[VK_F4]        = Key::F4;
-			s_translateKey[VK_F5]        = Key::F5;
-			s_translateKey[VK_F6]        = Key::F6;
-			s_translateKey[VK_F7]        = Key::F7;
-			s_translateKey[VK_F8]        = Key::F8;
-			s_translateKey[VK_F9]        = Key::F9;
-			s_translateKey[VK_F10]       = Key::F10;
-			s_translateKey[VK_F11]       = Key::F11;
-			s_translateKey[VK_F12]       = Key::F12;
-			s_translateKey[VK_NUMPAD0]   = Key::NumPad0;
-			s_translateKey[VK_NUMPAD1]   = Key::NumPad1;
-			s_translateKey[VK_NUMPAD2]   = Key::NumPad2;
-			s_translateKey[VK_NUMPAD3]   = Key::NumPad3;
-			s_translateKey[VK_NUMPAD4]   = Key::NumPad4;
-			s_translateKey[VK_NUMPAD5]   = Key::NumPad5;
-			s_translateKey[VK_NUMPAD6]   = Key::NumPad6;
-			s_translateKey[VK_NUMPAD7]   = Key::NumPad7;
-			s_translateKey[VK_NUMPAD8]   = Key::NumPad8;
-			s_translateKey[VK_NUMPAD9]   = Key::NumPad9;
-			s_translateKey[uint8_t('0')] = Key::Key0;
-			s_translateKey[uint8_t('1')] = Key::Key1;
-			s_translateKey[uint8_t('2')] = Key::Key2;
-			s_translateKey[uint8_t('3')] = Key::Key3;
-			s_translateKey[uint8_t('4')] = Key::Key4;
-			s_translateKey[uint8_t('5')] = Key::Key5;
-			s_translateKey[uint8_t('6')] = Key::Key6;
-			s_translateKey[uint8_t('7')] = Key::Key7;
-			s_translateKey[uint8_t('8')] = Key::Key8;
-			s_translateKey[uint8_t('9')] = Key::Key9;
-			s_translateKey[uint8_t('A')] = Key::KeyA;
-			s_translateKey[uint8_t('B')] = Key::KeyB;
-			s_translateKey[uint8_t('C')] = Key::KeyC;
-			s_translateKey[uint8_t('D')] = Key::KeyD;
-			s_translateKey[uint8_t('E')] = Key::KeyE;
-			s_translateKey[uint8_t('F')] = Key::KeyF;
-			s_translateKey[uint8_t('G')] = Key::KeyG;
-			s_translateKey[uint8_t('H')] = Key::KeyH;
-			s_translateKey[uint8_t('I')] = Key::KeyI;
-			s_translateKey[uint8_t('J')] = Key::KeyJ;
-			s_translateKey[uint8_t('K')] = Key::KeyK;
-			s_translateKey[uint8_t('L')] = Key::KeyL;
-			s_translateKey[uint8_t('M')] = Key::KeyM;
-			s_translateKey[uint8_t('N')] = Key::KeyN;
-			s_translateKey[uint8_t('O')] = Key::KeyO;
-			s_translateKey[uint8_t('P')] = Key::KeyP;
-			s_translateKey[uint8_t('Q')] = Key::KeyQ;
-			s_translateKey[uint8_t('R')] = Key::KeyR;
-			s_translateKey[uint8_t('S')] = Key::KeyS;
-			s_translateKey[uint8_t('T')] = Key::KeyT;
-			s_translateKey[uint8_t('U')] = Key::KeyU;
-			s_translateKey[uint8_t('V')] = Key::KeyV;
-			s_translateKey[uint8_t('W')] = Key::KeyW;
-			s_translateKey[uint8_t('X')] = Key::KeyX;
-			s_translateKey[uint8_t('Y')] = Key::KeyY;
-			s_translateKey[uint8_t('Z')] = Key::KeyZ;
+			s_translateKey[VK_ESCAPE]     = Key::Esc;
+			s_translateKey[VK_RETURN]     = Key::Return;
+			s_translateKey[VK_TAB]        = Key::Tab;
+			s_translateKey[VK_BACK]       = Key::Backspace;
+			s_translateKey[VK_SPACE]      = Key::Space;
+			s_translateKey[VK_UP]         = Key::Up;
+			s_translateKey[VK_DOWN]       = Key::Down;
+			s_translateKey[VK_LEFT]       = Key::Left;
+			s_translateKey[VK_RIGHT]      = Key::Right;
+			s_translateKey[VK_INSERT]     = Key::Insert;
+			s_translateKey[VK_DELETE]     = Key::Delete;
+			s_translateKey[VK_HOME]       = Key::Home;
+			s_translateKey[VK_END]        = Key::End;
+			s_translateKey[VK_PRIOR]      = Key::PageUp;
+			s_translateKey[VK_NEXT]       = Key::PageUp;
+			s_translateKey[VK_SNAPSHOT]   = Key::Print;
+			s_translateKey[VK_OEM_PLUS]   = Key::Plus;
+			s_translateKey[VK_OEM_MINUS]  = Key::Minus;
+			s_translateKey[VK_OEM_4]      = Key::LeftBracket;
+			s_translateKey[VK_OEM_6]      = Key::RightBracket;
+			s_translateKey[VK_OEM_1]      = Key::Semicolon;
+			s_translateKey[VK_OEM_7]      = Key::Quote;
+			s_translateKey[VK_OEM_COMMA]  = Key::Comma;
+			s_translateKey[VK_OEM_PERIOD] = Key::Period;
+			s_translateKey[VK_OEM_2]      = Key::Slash;
+			s_translateKey[VK_OEM_5]      = Key::Backslash;
+			s_translateKey[VK_OEM_3]      = Key::Tilda;
+			s_translateKey[VK_F1]         = Key::F1;
+			s_translateKey[VK_F2]         = Key::F2;
+			s_translateKey[VK_F3]         = Key::F3;
+			s_translateKey[VK_F4]         = Key::F4;
+			s_translateKey[VK_F5]         = Key::F5;
+			s_translateKey[VK_F6]         = Key::F6;
+			s_translateKey[VK_F7]         = Key::F7;
+			s_translateKey[VK_F8]         = Key::F8;
+			s_translateKey[VK_F9]         = Key::F9;
+			s_translateKey[VK_F10]        = Key::F10;
+			s_translateKey[VK_F11]        = Key::F11;
+			s_translateKey[VK_F12]        = Key::F12;
+			s_translateKey[VK_NUMPAD0]    = Key::NumPad0;
+			s_translateKey[VK_NUMPAD1]    = Key::NumPad1;
+			s_translateKey[VK_NUMPAD2]    = Key::NumPad2;
+			s_translateKey[VK_NUMPAD3]    = Key::NumPad3;
+			s_translateKey[VK_NUMPAD4]    = Key::NumPad4;
+			s_translateKey[VK_NUMPAD5]    = Key::NumPad5;
+			s_translateKey[VK_NUMPAD6]    = Key::NumPad6;
+			s_translateKey[VK_NUMPAD7]    = Key::NumPad7;
+			s_translateKey[VK_NUMPAD8]    = Key::NumPad8;
+			s_translateKey[VK_NUMPAD9]    = Key::NumPad9;
+			s_translateKey[uint8_t('0')]  = Key::Key0;
+			s_translateKey[uint8_t('1')]  = Key::Key1;
+			s_translateKey[uint8_t('2')]  = Key::Key2;
+			s_translateKey[uint8_t('3')]  = Key::Key3;
+			s_translateKey[uint8_t('4')]  = Key::Key4;
+			s_translateKey[uint8_t('5')]  = Key::Key5;
+			s_translateKey[uint8_t('6')]  = Key::Key6;
+			s_translateKey[uint8_t('7')]  = Key::Key7;
+			s_translateKey[uint8_t('8')]  = Key::Key8;
+			s_translateKey[uint8_t('9')]  = Key::Key9;
+			s_translateKey[uint8_t('A')]  = Key::KeyA;
+			s_translateKey[uint8_t('B')]  = Key::KeyB;
+			s_translateKey[uint8_t('C')]  = Key::KeyC;
+			s_translateKey[uint8_t('D')]  = Key::KeyD;
+			s_translateKey[uint8_t('E')]  = Key::KeyE;
+			s_translateKey[uint8_t('F')]  = Key::KeyF;
+			s_translateKey[uint8_t('G')]  = Key::KeyG;
+			s_translateKey[uint8_t('H')]  = Key::KeyH;
+			s_translateKey[uint8_t('I')]  = Key::KeyI;
+			s_translateKey[uint8_t('J')]  = Key::KeyJ;
+			s_translateKey[uint8_t('K')]  = Key::KeyK;
+			s_translateKey[uint8_t('L')]  = Key::KeyL;
+			s_translateKey[uint8_t('M')]  = Key::KeyM;
+			s_translateKey[uint8_t('N')]  = Key::KeyN;
+			s_translateKey[uint8_t('O')]  = Key::KeyO;
+			s_translateKey[uint8_t('P')]  = Key::KeyP;
+			s_translateKey[uint8_t('Q')]  = Key::KeyQ;
+			s_translateKey[uint8_t('R')]  = Key::KeyR;
+			s_translateKey[uint8_t('S')]  = Key::KeyS;
+			s_translateKey[uint8_t('T')]  = Key::KeyT;
+			s_translateKey[uint8_t('U')]  = Key::KeyU;
+			s_translateKey[uint8_t('V')]  = Key::KeyV;
+			s_translateKey[uint8_t('W')]  = Key::KeyW;
+			s_translateKey[uint8_t('X')]  = Key::KeyX;
+			s_translateKey[uint8_t('Y')]  = Key::KeyY;
+			s_translateKey[uint8_t('Z')]  = Key::KeyZ;
 		}
 
 		int32_t run(int _argc, char** _argv)