From 09a24a17d717b0918a891d282f60441b5ad73917 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 28 Jun 2009 10:27:17 +0000 Subject: [PATCH] Removed Key.None and Key.MaxKeys. Added XML documentation to all OpenTK.Input.Key tokens. Added typical Key names found in Windows.Forms and XNA: LControl, RControl, ... --- Source/OpenTK/Input/KeyboardDevice.cs | 240 ++++++++++++++++++++++++-- 1 file changed, 221 insertions(+), 19 deletions(-) diff --git a/Source/OpenTK/Input/KeyboardDevice.cs b/Source/OpenTK/Input/KeyboardDevice.cs index a7e1a7b0..b16413c6 100644 --- a/Source/OpenTK/Input/KeyboardDevice.cs +++ b/Source/OpenTK/Input/KeyboardDevice.cs @@ -21,7 +21,7 @@ namespace OpenTK.Input public sealed class KeyboardDevice : IInputDevice { //private IKeyboard keyboard; - private bool[] keys = new bool[(int)Key.MaxKeys]; + private bool[] keys = new bool[Enum.GetValues(typeof(Key)).Length]; private string description; private int numKeys, numFKeys, numLeds; private IntPtr devID; @@ -183,7 +183,7 @@ namespace OpenTK.Input internal void ClearKeys() { - for (int i = 0; i < (int)Key.MaxKeys; i++) + for (int i = 0; i < keys.Length; i++) if (this[(Key)i]) // Make sure KeyUp events are *not* raised for keys that are up, even if key repeat is on. this[(Key)i] = false; } @@ -203,56 +203,167 @@ namespace OpenTK.Input /// public enum Key : int { - None = 0, + /// A key outside the known keys. + Unknown = 0, // Modifiers + /// The left shift key. ShiftLeft, + /// The left shift key (equivalent to ShiftLeft). + LShift = ShiftLeft, + /// The right shift key. ShiftRight, + /// The right shift key (equivalent to ShiftRight). + RShift = ShiftRight, + /// The left control key. ControlLeft, + /// The left control key (equivalent to ControlLeft). + LControl = ControlLeft, + /// The right control key. ControlRight, + /// The right control key (equivalent to ControlRight). + RControl = ControlRight, + /// The left alt key. AltLeft, + /// The left alt key (equivalent to AltLeft. + LAlt = AltLeft, + /// The right alt key. AltRight, + /// The right alt key (equivalent to AltRight). + RAlt = AltRight, + /// The left win key. WinLeft, + /// The left win key (equivalent to WinLeft). + LWin = WinLeft, + /// The right win key. WinRight, + /// The right win key (equivalent to WinRight). + RWin = WinRight, + /// The menu key. Menu, // Function keys (hopefully enough for most keyboards - mine has 26) // on X11 reports up to 35 function keys. - F1, F2, F3, F4, - F5, F6, F7, F8, - F9, F10, F11, F12, - F13, F14, F15, F16, - F17, F18, F19, F20, - F21, F22, F23, F24, - F25, F26, F27, F28, - F29, F30, F31, F32, - F33, F34, F35, + /// The F1 key. + F1, + /// The F2 key. + F2, + /// The F3 key. + F3, + /// The F4 key. + F4, + /// The F5 key. + F5, + /// The F6 key. + F6, + /// The F7 key. + F7, + /// The F8 key. + F8, + /// The F9 key. + F9, + /// The F10 key. + F10, + /// The F11 key. + F11, + /// The F12 key. + F12, + /// The F13 key. + F13, + /// The F14 key. + F14, + /// The F15 key. + F15, + /// The F16 key. + F16, + /// The F17 key. + F17, + /// The F18 key. + F18, + /// The F19 key. + F19, + /// The F20 key. + F20, + /// The F21 key. + F21, + /// The F22 key. + F22, + /// The F23 key. + F23, + /// The F24 key. + F24, + /// The F25 key. + F25, + /// The F26 key. + F26, + /// The F27 key. + F27, + /// The F28 key. + F28, + /// The F29 key. + F29, + /// The F30 key. + F30, + /// The F31 key. + F31, + /// The F32 key. + F32, + /// The F33 key. + F33, + /// The F34 key. + F34, + /// The F35 key. + F35, // Direction arrows + /// The up arrow key. Up, + /// The down arrow key. Down, + /// The left arrow key. Left, + /// The right arrow key. Right, + /// The enter key. Enter, + /// The escape key. Escape, + /// The space key. Space, + /// The tab key. Tab, + /// The backspace key. BackSpace, + /// The backspace key (equivalent to BackSpace). + Back = BackSpace, + /// The insert key. Insert, + /// The delete key. Delete, + /// The page up key. PageUp, + /// The page down key. PageDown, + /// The home key. Home, + /// The end key. End, + /// The caps lock key. CapsLock, + /// The scroll lock key. ScrollLock, + /// The print screen key. PrintScreen, + /// The pause key. Pause, + /// The num lock key. NumLock, // Special keys - Clear, // Keypad5 with NumLock off. + /// The clear key (Keypad5 with NumLock disabled, on typical keyboards). + Clear, + /// The sleep key. Sleep, /*LogOff, Help, @@ -287,56 +398,147 @@ namespace OpenTK.Input TrackNext,*/ // Keypad keys + /// The keypad 0 key. Keypad0, + /// The keypad 1 key. Keypad1, + /// The keypad 2 key. Keypad2, + /// The keypad 3 key. Keypad3, + /// The keypad 4 key. Keypad4, + /// The keypad 5 key. Keypad5, + /// The keypad 6 key. Keypad6, + /// The keypad 7 key. Keypad7, + /// The keypad 8 key. Keypad8, + /// The keypad 9 key. Keypad9, + /// The keypad divide key. KeypadDivide, + /// The keypad multiply key. KeypadMultiply, + /// The keypad subtract key. KeypadSubtract, + /// The keypad minus key (equivalent to KeypadSubtract). + KeypadMinus = KeypadSubtract, + /// The keypad add key. KeypadAdd, + /// The keypad plus key (equivalent to KeypadAdd). + KeypadPlus = KeypadAdd, + /// The keypad decimal key. KeypadDecimal, + /// The keypad enter key. KeypadEnter, // Letters - A, B, C, D, E, F, G, - H, I, J, K, L, M, N, - O, P, Q, R, S, T, U, - V, W, X, Y, Z, + /// The A key. + A, + /// The B key. + B, + /// The C key. + C, + /// The D key. + D, + /// The E key. + E, + /// The F key. + F, + /// The G key. + G, + /// The H key. + H, + /// The I key. + I, + /// The J key. + J, + /// The K key. + K, + /// The L key. + L, + /// The M key. + M, + /// The N key. + N, + /// The O key. + O, + /// The P key. + P, + /// The Q key. + Q, + /// The R key. + R, + /// The S key. + S, + /// The T key. + T, + /// The U key. + U, + /// The V key. + V, + /// The W key. + W, + /// The X key. + X, + /// The Y key. + Y, + /// The Z key. + Z, // Numbers + /// The number 0 key. Number0, + /// The number 1 key. Number1, + /// The number 2 key. Number2, + /// The number 3 key. Number3, + /// The number 4 key. Number4, + /// The number 5 key. Number5, + /// The number 6 key. Number6, + /// The number 7 key. Number7, + /// The number 8 key. Number8, + /// The number 9 key. Number9, // Symbols + /// The tilde key. Tilde, + /// The minus key. Minus, //Equal, + /// The plus key. Plus, + /// The left bracket key. BracketLeft, + /// The left bracket key (equivalent to BracketLeft). + LBracket = BracketLeft, + /// The right bracket key. BracketRight, + /// The right bracket key (equivalent to BracketRight). + RBracket = BracketRight, + /// The semicolon key. Semicolon, + /// The quote key. Quote, + /// The comma key. Comma, + /// The period key. Period, + /// The slash key. Slash, + /// The backslash key. BackSlash, - - MaxKeys } #endregion