private bool GetKeyState(SDL_Scancode key) { var index = (int)key; if (index >= _keyboardStateCount || index >= _keyboardState.Length) { return(false); } return(_keyboardState[index] != 0); }
public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE(SDL_Scancode X) { return (SDL_Keycode)((int)X | SDLK_SCANCODE_MASK); }
public static void SendKeyboardEvent(SdlKeyState state, SDL_Scancode key) => SDL_SendKeyboardKey((byte)state, (int)key);
private static KeyboardKey MapKey(SDL_Scancode scanCode) { return(scanCode switch { SDL_Scancode.SDL_SCANCODE_A => KeyboardKey.A, SDL_Scancode.SDL_SCANCODE_B => KeyboardKey.B, SDL_Scancode.SDL_SCANCODE_C => KeyboardKey.C, SDL_Scancode.SDL_SCANCODE_D => KeyboardKey.D, SDL_Scancode.SDL_SCANCODE_E => KeyboardKey.E, SDL_Scancode.SDL_SCANCODE_F => KeyboardKey.F, SDL_Scancode.SDL_SCANCODE_G => KeyboardKey.G, SDL_Scancode.SDL_SCANCODE_H => KeyboardKey.H, SDL_Scancode.SDL_SCANCODE_I => KeyboardKey.I, SDL_Scancode.SDL_SCANCODE_J => KeyboardKey.J, SDL_Scancode.SDL_SCANCODE_K => KeyboardKey.K, SDL_Scancode.SDL_SCANCODE_L => KeyboardKey.L, SDL_Scancode.SDL_SCANCODE_M => KeyboardKey.M, SDL_Scancode.SDL_SCANCODE_N => KeyboardKey.N, SDL_Scancode.SDL_SCANCODE_O => KeyboardKey.O, SDL_Scancode.SDL_SCANCODE_P => KeyboardKey.P, SDL_Scancode.SDL_SCANCODE_Q => KeyboardKey.Q, SDL_Scancode.SDL_SCANCODE_R => KeyboardKey.R, SDL_Scancode.SDL_SCANCODE_S => KeyboardKey.S, SDL_Scancode.SDL_SCANCODE_T => KeyboardKey.T, SDL_Scancode.SDL_SCANCODE_U => KeyboardKey.U, SDL_Scancode.SDL_SCANCODE_V => KeyboardKey.V, SDL_Scancode.SDL_SCANCODE_W => KeyboardKey.W, SDL_Scancode.SDL_SCANCODE_X => KeyboardKey.X, SDL_Scancode.SDL_SCANCODE_Y => KeyboardKey.Y, SDL_Scancode.SDL_SCANCODE_Z => KeyboardKey.Z, SDL_Scancode.SDL_SCANCODE_1 => KeyboardKey.Number1, SDL_Scancode.SDL_SCANCODE_2 => KeyboardKey.Number2, SDL_Scancode.SDL_SCANCODE_3 => KeyboardKey.Number3, SDL_Scancode.SDL_SCANCODE_4 => KeyboardKey.Number4, SDL_Scancode.SDL_SCANCODE_5 => KeyboardKey.Number5, SDL_Scancode.SDL_SCANCODE_6 => KeyboardKey.Number6, SDL_Scancode.SDL_SCANCODE_7 => KeyboardKey.Number7, SDL_Scancode.SDL_SCANCODE_8 => KeyboardKey.Number8, SDL_Scancode.SDL_SCANCODE_9 => KeyboardKey.Number9, SDL_Scancode.SDL_SCANCODE_0 => KeyboardKey.Number0, SDL_Scancode.SDL_SCANCODE_RETURN => KeyboardKey.Enter, SDL_Scancode.SDL_SCANCODE_ESCAPE => KeyboardKey.Escape, SDL_Scancode.SDL_SCANCODE_BACKSPACE => KeyboardKey.BackSpace, SDL_Scancode.SDL_SCANCODE_TAB => KeyboardKey.Tab, SDL_Scancode.SDL_SCANCODE_SPACE => KeyboardKey.Space, SDL_Scancode.SDL_SCANCODE_MINUS => KeyboardKey.Minus, SDL_Scancode.SDL_SCANCODE_EQUALS => KeyboardKey.Plus, SDL_Scancode.SDL_SCANCODE_LEFTBRACKET => KeyboardKey.BracketLeft, SDL_Scancode.SDL_SCANCODE_RIGHTBRACKET => KeyboardKey.BracketRight, SDL_Scancode.SDL_SCANCODE_BACKSLASH => KeyboardKey.BackSlash, SDL_Scancode.SDL_SCANCODE_SEMICOLON => KeyboardKey.Semicolon, SDL_Scancode.SDL_SCANCODE_APOSTROPHE => KeyboardKey.Quote, SDL_Scancode.SDL_SCANCODE_GRAVE => KeyboardKey.Grave, SDL_Scancode.SDL_SCANCODE_COMMA => KeyboardKey.Comma, SDL_Scancode.SDL_SCANCODE_PERIOD => KeyboardKey.Period, SDL_Scancode.SDL_SCANCODE_SLASH => KeyboardKey.Slash, SDL_Scancode.SDL_SCANCODE_CAPSLOCK => KeyboardKey.CapsLock, SDL_Scancode.SDL_SCANCODE_F1 => KeyboardKey.F1, SDL_Scancode.SDL_SCANCODE_F2 => KeyboardKey.F2, SDL_Scancode.SDL_SCANCODE_F3 => KeyboardKey.F3, SDL_Scancode.SDL_SCANCODE_F4 => KeyboardKey.F4, SDL_Scancode.SDL_SCANCODE_F5 => KeyboardKey.F5, SDL_Scancode.SDL_SCANCODE_F6 => KeyboardKey.F6, SDL_Scancode.SDL_SCANCODE_F7 => KeyboardKey.F7, SDL_Scancode.SDL_SCANCODE_F8 => KeyboardKey.F8, SDL_Scancode.SDL_SCANCODE_F9 => KeyboardKey.F9, SDL_Scancode.SDL_SCANCODE_F10 => KeyboardKey.F10, SDL_Scancode.SDL_SCANCODE_F11 => KeyboardKey.F11, SDL_Scancode.SDL_SCANCODE_F12 => KeyboardKey.F12, SDL_Scancode.SDL_SCANCODE_PRINTSCREEN => KeyboardKey.PrintScreen, SDL_Scancode.SDL_SCANCODE_SCROLLLOCK => KeyboardKey.ScrollLock, SDL_Scancode.SDL_SCANCODE_PAUSE => KeyboardKey.Pause, SDL_Scancode.SDL_SCANCODE_INSERT => KeyboardKey.Insert, SDL_Scancode.SDL_SCANCODE_HOME => KeyboardKey.Home, SDL_Scancode.SDL_SCANCODE_PAGEUP => KeyboardKey.PageUp, SDL_Scancode.SDL_SCANCODE_DELETE => KeyboardKey.Delete, SDL_Scancode.SDL_SCANCODE_END => KeyboardKey.End, SDL_Scancode.SDL_SCANCODE_PAGEDOWN => KeyboardKey.PageDown, SDL_Scancode.SDL_SCANCODE_RIGHT => KeyboardKey.Right, SDL_Scancode.SDL_SCANCODE_LEFT => KeyboardKey.Left, SDL_Scancode.SDL_SCANCODE_DOWN => KeyboardKey.Down, SDL_Scancode.SDL_SCANCODE_UP => KeyboardKey.Up, SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR => KeyboardKey.NumLock, SDL_Scancode.SDL_SCANCODE_KP_DIVIDE => KeyboardKey.KeypadDivide, SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY => KeyboardKey.KeypadMultiply, SDL_Scancode.SDL_SCANCODE_KP_MINUS => KeyboardKey.KeypadMinus, SDL_Scancode.SDL_SCANCODE_KP_PLUS => KeyboardKey.KeypadPlus, SDL_Scancode.SDL_SCANCODE_KP_ENTER => KeyboardKey.KeypadEnter, SDL_Scancode.SDL_SCANCODE_KP_1 => KeyboardKey.Keypad1, SDL_Scancode.SDL_SCANCODE_KP_2 => KeyboardKey.Keypad2, SDL_Scancode.SDL_SCANCODE_KP_3 => KeyboardKey.Keypad3, SDL_Scancode.SDL_SCANCODE_KP_4 => KeyboardKey.Keypad4, SDL_Scancode.SDL_SCANCODE_KP_5 => KeyboardKey.Keypad5, SDL_Scancode.SDL_SCANCODE_KP_6 => KeyboardKey.Keypad6, SDL_Scancode.SDL_SCANCODE_KP_7 => KeyboardKey.Keypad7, SDL_Scancode.SDL_SCANCODE_KP_8 => KeyboardKey.Keypad8, SDL_Scancode.SDL_SCANCODE_KP_9 => KeyboardKey.Keypad9, SDL_Scancode.SDL_SCANCODE_KP_0 => KeyboardKey.Keypad0, SDL_Scancode.SDL_SCANCODE_KP_PERIOD => KeyboardKey.KeypadPeriod, SDL_Scancode.SDL_SCANCODE_NONUSBACKSLASH => KeyboardKey.NonUsBackSlash, SDL_Scancode.SDL_SCANCODE_KP_EQUALS => KeyboardKey.KeypadPlus, SDL_Scancode.SDL_SCANCODE_F13 => KeyboardKey.F13, SDL_Scancode.SDL_SCANCODE_F14 => KeyboardKey.F14, SDL_Scancode.SDL_SCANCODE_F15 => KeyboardKey.F15, SDL_Scancode.SDL_SCANCODE_F16 => KeyboardKey.F16, SDL_Scancode.SDL_SCANCODE_F17 => KeyboardKey.F17, SDL_Scancode.SDL_SCANCODE_F18 => KeyboardKey.F18, SDL_Scancode.SDL_SCANCODE_F19 => KeyboardKey.F19, SDL_Scancode.SDL_SCANCODE_F20 => KeyboardKey.F20, SDL_Scancode.SDL_SCANCODE_F21 => KeyboardKey.F21, SDL_Scancode.SDL_SCANCODE_F22 => KeyboardKey.F22, SDL_Scancode.SDL_SCANCODE_F23 => KeyboardKey.F23, SDL_Scancode.SDL_SCANCODE_F24 => KeyboardKey.F24, SDL_Scancode.SDL_SCANCODE_MENU => KeyboardKey.Menu, SDL_Scancode.SDL_SCANCODE_LCTRL => KeyboardKey.ControlLeft, SDL_Scancode.SDL_SCANCODE_LSHIFT => KeyboardKey.ShiftLeft, SDL_Scancode.SDL_SCANCODE_LALT => KeyboardKey.AltLeft, SDL_Scancode.SDL_SCANCODE_RCTRL => KeyboardKey.ControlRight, SDL_Scancode.SDL_SCANCODE_RSHIFT => KeyboardKey.ShiftRight, SDL_Scancode.SDL_SCANCODE_RALT => KeyboardKey.AltRight, _ => KeyboardKey.Unknown });
public static extern string SDL_GetScancodeName( SDL_Scancode scancode);
public static extern System.Int32 SDL_GetKeyFromScancode( SDL_Scancode scancode);
public static Buttons ToCrystal(this SDL_Scancode self) { switch (self) { case SDL_Scancode.SDL_SCANCODE_UNKNOWN: return(Buttons.None); case SDL_Scancode.SDL_SCANCODE_SPACE: return(Buttons.Space); case SDL_Scancode.SDL_SCANCODE_APOSTROPHE: return(Buttons.Apostrophe); case SDL_Scancode.SDL_SCANCODE_COMMA: return(Buttons.Comma); case SDL_Scancode.SDL_SCANCODE_MINUS: return(Buttons.Minus); case SDL_Scancode.SDL_SCANCODE_PERIOD: return(Buttons.Period); case SDL_Scancode.SDL_SCANCODE_SLASH: return(Buttons.Slash); case SDL_Scancode.SDL_SCANCODE_0: return(Buttons.Zero); case SDL_Scancode.SDL_SCANCODE_1: return(Buttons.One); case SDL_Scancode.SDL_SCANCODE_2: return(Buttons.Two); case SDL_Scancode.SDL_SCANCODE_3: return(Buttons.Three); case SDL_Scancode.SDL_SCANCODE_4: return(Buttons.Four); case SDL_Scancode.SDL_SCANCODE_5: return(Buttons.Five); case SDL_Scancode.SDL_SCANCODE_6: return(Buttons.Six); case SDL_Scancode.SDL_SCANCODE_7: return(Buttons.Seven); case SDL_Scancode.SDL_SCANCODE_8: return(Buttons.Eight); case SDL_Scancode.SDL_SCANCODE_9: return(Buttons.Nine); case SDL_Scancode.SDL_SCANCODE_SEMICOLON: return(Buttons.Semicolon); case SDL_Scancode.SDL_SCANCODE_EQUALS: return(Buttons.Equal); case SDL_Scancode.SDL_SCANCODE_A: return(Buttons.A); case SDL_Scancode.SDL_SCANCODE_B: return(Buttons.B); case SDL_Scancode.SDL_SCANCODE_C: return(Buttons.C); case SDL_Scancode.SDL_SCANCODE_D: return(Buttons.D); case SDL_Scancode.SDL_SCANCODE_E: return(Buttons.E); case SDL_Scancode.SDL_SCANCODE_F: return(Buttons.F); case SDL_Scancode.SDL_SCANCODE_G: return(Buttons.G); case SDL_Scancode.SDL_SCANCODE_H: return(Buttons.H); case SDL_Scancode.SDL_SCANCODE_I: return(Buttons.I); case SDL_Scancode.SDL_SCANCODE_J: return(Buttons.J); case SDL_Scancode.SDL_SCANCODE_K: return(Buttons.K); case SDL_Scancode.SDL_SCANCODE_L: return(Buttons.L); case SDL_Scancode.SDL_SCANCODE_M: return(Buttons.M); case SDL_Scancode.SDL_SCANCODE_N: return(Buttons.N); case SDL_Scancode.SDL_SCANCODE_O: return(Buttons.O); case SDL_Scancode.SDL_SCANCODE_P: return(Buttons.P); case SDL_Scancode.SDL_SCANCODE_Q: return(Buttons.Q); case SDL_Scancode.SDL_SCANCODE_R: return(Buttons.R); case SDL_Scancode.SDL_SCANCODE_S: return(Buttons.S); case SDL_Scancode.SDL_SCANCODE_T: return(Buttons.T); case SDL_Scancode.SDL_SCANCODE_U: return(Buttons.U); case SDL_Scancode.SDL_SCANCODE_V: return(Buttons.V); case SDL_Scancode.SDL_SCANCODE_W: return(Buttons.W); case SDL_Scancode.SDL_SCANCODE_X: return(Buttons.X); case SDL_Scancode.SDL_SCANCODE_Y: return(Buttons.Y); case SDL_Scancode.SDL_SCANCODE_Z: return(Buttons.Z); case SDL_Scancode.SDL_SCANCODE_LEFTBRACKET: return(Buttons.LeftBracket); case SDL_Scancode.SDL_SCANCODE_BACKSLASH: return(Buttons.Backslash); case SDL_Scancode.SDL_SCANCODE_RIGHTBRACKET: return(Buttons.RightBracket); case SDL_Scancode.SDL_SCANCODE_GRAVE: return(Buttons.GraveAccent); case SDL_Scancode.SDL_SCANCODE_ESCAPE: return(Buttons.Escape); case SDL_Scancode.SDL_SCANCODE_RETURN: return(Buttons.Enter); case SDL_Scancode.SDL_SCANCODE_TAB: return(Buttons.Tab); case SDL_Scancode.SDL_SCANCODE_BACKSPACE: return(Buttons.Backspace); case SDL_Scancode.SDL_SCANCODE_INSERT: return(Buttons.Insert); case SDL_Scancode.SDL_SCANCODE_DELETE: return(Buttons.Delete); case SDL_Scancode.SDL_SCANCODE_RIGHT: return(Buttons.Right); case SDL_Scancode.SDL_SCANCODE_LEFT: return(Buttons.Left); case SDL_Scancode.SDL_SCANCODE_DOWN: return(Buttons.Down); case SDL_Scancode.SDL_SCANCODE_UP: return(Buttons.Up); case SDL_Scancode.SDL_SCANCODE_PAGEUP: return(Buttons.PageUp); case SDL_Scancode.SDL_SCANCODE_PAGEDOWN: return(Buttons.PageDown); case SDL_Scancode.SDL_SCANCODE_HOME: return(Buttons.Home); case SDL_Scancode.SDL_SCANCODE_END: return(Buttons.End); case SDL_Scancode.SDL_SCANCODE_CAPSLOCK: return(Buttons.CapsLock); case SDL_Scancode.SDL_SCANCODE_SCROLLLOCK: return(Buttons.ScrollLock); case SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR: return(Buttons.NumLock); case SDL_Scancode.SDL_SCANCODE_PRINTSCREEN: return(Buttons.PrintScreen); case SDL_Scancode.SDL_SCANCODE_PAUSE: return(Buttons.Pause); case SDL_Scancode.SDL_SCANCODE_F1: return(Buttons.F1); case SDL_Scancode.SDL_SCANCODE_F2: return(Buttons.F2); case SDL_Scancode.SDL_SCANCODE_F3: return(Buttons.F3); case SDL_Scancode.SDL_SCANCODE_F4: return(Buttons.F4); case SDL_Scancode.SDL_SCANCODE_F5: return(Buttons.F5); case SDL_Scancode.SDL_SCANCODE_F6: return(Buttons.F6); case SDL_Scancode.SDL_SCANCODE_F7: return(Buttons.F7); case SDL_Scancode.SDL_SCANCODE_F8: return(Buttons.F8); case SDL_Scancode.SDL_SCANCODE_F9: return(Buttons.F9); case SDL_Scancode.SDL_SCANCODE_F10: return(Buttons.F10); case SDL_Scancode.SDL_SCANCODE_F11: return(Buttons.F11); case SDL_Scancode.SDL_SCANCODE_F12: return(Buttons.F12); case SDL_Scancode.SDL_SCANCODE_F13: return(Buttons.F13); case SDL_Scancode.SDL_SCANCODE_F14: return(Buttons.F14); case SDL_Scancode.SDL_SCANCODE_F15: return(Buttons.F15); case SDL_Scancode.SDL_SCANCODE_F16: return(Buttons.F16); case SDL_Scancode.SDL_SCANCODE_F17: return(Buttons.F17); case SDL_Scancode.SDL_SCANCODE_F18: return(Buttons.F18); case SDL_Scancode.SDL_SCANCODE_F19: return(Buttons.F19); case SDL_Scancode.SDL_SCANCODE_F20: return(Buttons.F20); case SDL_Scancode.SDL_SCANCODE_F21: return(Buttons.F21); case SDL_Scancode.SDL_SCANCODE_F22: return(Buttons.F22); case SDL_Scancode.SDL_SCANCODE_F23: return(Buttons.F23); case SDL_Scancode.SDL_SCANCODE_F24: return(Buttons.F24); case SDL_Scancode.SDL_SCANCODE_KP_0: return(Buttons.KeypadZero); case SDL_Scancode.SDL_SCANCODE_KP_1: return(Buttons.KeypadOne); case SDL_Scancode.SDL_SCANCODE_KP_2: return(Buttons.KeypadTwo); case SDL_Scancode.SDL_SCANCODE_KP_3: return(Buttons.KeypadThree); case SDL_Scancode.SDL_SCANCODE_KP_4: return(Buttons.KeypadFour); case SDL_Scancode.SDL_SCANCODE_KP_5: return(Buttons.KeypadFive); case SDL_Scancode.SDL_SCANCODE_KP_6: return(Buttons.KeypadSix); case SDL_Scancode.SDL_SCANCODE_KP_7: return(Buttons.KeypadSeven); case SDL_Scancode.SDL_SCANCODE_KP_8: return(Buttons.KeypadEight); case SDL_Scancode.SDL_SCANCODE_KP_9: return(Buttons.KeypadNine); case SDL_Scancode.SDL_SCANCODE_KP_DECIMAL: return(Buttons.KeypadDecimal); case SDL_Scancode.SDL_SCANCODE_KP_DIVIDE: return(Buttons.KeypadDivide); case SDL_Scancode.SDL_SCANCODE_KP_MULTIPLY: return(Buttons.KeypadMultiply); case SDL_Scancode.SDL_SCANCODE_KP_MINUS: return(Buttons.KeypadSubtract); case SDL_Scancode.SDL_SCANCODE_KP_PLUS: return(Buttons.KeypadAdd); case SDL_Scancode.SDL_SCANCODE_KP_ENTER: return(Buttons.KeypadEnter); case SDL_Scancode.SDL_SCANCODE_KP_EQUALS: return(Buttons.KeypadEqual); case SDL_Scancode.SDL_SCANCODE_LSHIFT: return(Buttons.LeftShift); case SDL_Scancode.SDL_SCANCODE_LCTRL: return(Buttons.LeftControl); case SDL_Scancode.SDL_SCANCODE_LALT: return(Buttons.LeftAlt); case SDL_Scancode.SDL_SCANCODE_LGUI: return(Buttons.LeftSuper); case SDL_Scancode.SDL_SCANCODE_RSHIFT: return(Buttons.RightShift); case SDL_Scancode.SDL_SCANCODE_RCTRL: return(Buttons.RightControl); case SDL_Scancode.SDL_SCANCODE_RALT: return(Buttons.RightAlt); case SDL_Scancode.SDL_SCANCODE_RGUI: return(Buttons.RightSuper); default: return(Buttons.None); } }
/* Get a human-readable name for a scancode */ public static string SDL_GetScancodeName(SDL_Scancode scancode) { return Marshal.PtrToStringAnsi( INTERNAL_SDL_GetScancodeName(scancode) ); }
private static extern IntPtr INTERNAL_SDL_GetScancodeName(SDL_Scancode scancode);
public static extern void SDL_GetKeyFromScancode(SDL_Scancode scancode);
public static IntPtr SDL_GetScancodeName(SDL_Scancode scancode) => s_SDL_GetScancodeName_SDL_Scancode_t(scancode);
public static SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode) => s_SDL_GetKeyFromScancode_SDL_Scancode_t(scancode);
private Key ConvertKey(SDL_Scancode scanCode) { switch (scanCode) { case SDL_Scancode.SDL_SCANCODE_F1: return(Key.F1); case SDL_Scancode.SDL_SCANCODE_F2: return(Key.F2); case SDL_Scancode.SDL_SCANCODE_F3: return(Key.F3); case SDL_Scancode.SDL_SCANCODE_F4: return(Key.F4); case SDL_Scancode.SDL_SCANCODE_F5: return(Key.F5); case SDL_Scancode.SDL_SCANCODE_F6: return(Key.F6); case SDL_Scancode.SDL_SCANCODE_F7: return(Key.F7); case SDL_Scancode.SDL_SCANCODE_F8: return(Key.F8); case SDL_Scancode.SDL_SCANCODE_F9: return(Key.F9); case SDL_Scancode.SDL_SCANCODE_F10: return(Key.F10); case SDL_Scancode.SDL_SCANCODE_F11: return(Key.F11); case SDL_Scancode.SDL_SCANCODE_F12: return(Key.F12); case SDL_Scancode.SDL_SCANCODE_SLASH: case SDL_Scancode.SDL_SCANCODE_KP_DIVIDE: return(Key.Slash); case SDL_Scancode.SDL_SCANCODE_RETURN: case SDL_Scancode.SDL_SCANCODE_KP_ENTER: return(Key.Enter); case SDL_Scancode.SDL_SCANCODE_ESCAPE: return(Key.Escape); case SDL_Scancode.SDL_SCANCODE_BACKSPACE: return(Key.Backspace); case SDL_Scancode.SDL_SCANCODE_HOME: return(Key.Home); case SDL_Scancode.SDL_SCANCODE_END: return(Key.End); case SDL_Scancode.SDL_SCANCODE_DELETE: return(Key.Delete); case SDL_Scancode.SDL_SCANCODE_UP: return(Key.Up); case SDL_Scancode.SDL_SCANCODE_DOWN: return(Key.Down); case SDL_Scancode.SDL_SCANCODE_LEFT: return(Key.Left); case SDL_Scancode.SDL_SCANCODE_RIGHT: return(Key.Right); case SDL_Scancode.SDL_SCANCODE_SPACE: return(Key.Space); case SDL_Scancode.SDL_SCANCODE_KP_MINUS: return(Key.Minus); case SDL_Scancode.SDL_SCANCODE_KP_PLUS: return(Key.Plus); case SDL_Scancode.SDL_SCANCODE_KP_0: return(Key.NumPad0); case SDL_Scancode.SDL_SCANCODE_KP_1: return(Key.NumPad1); case SDL_Scancode.SDL_SCANCODE_KP_2: return(Key.NumPad2); case SDL_Scancode.SDL_SCANCODE_KP_3: return(Key.NumPad3); case SDL_Scancode.SDL_SCANCODE_KP_4: return(Key.NumPad4); case SDL_Scancode.SDL_SCANCODE_KP_5: return(Key.NumPad5); case SDL_Scancode.SDL_SCANCODE_KP_6: return(Key.NumPad6); case SDL_Scancode.SDL_SCANCODE_KP_7: return(Key.NumPad7); case SDL_Scancode.SDL_SCANCODE_KP_8: return(Key.NumPad8); case SDL_Scancode.SDL_SCANCODE_KP_9: return(Key.NumPad9); } return(Key.None); }
public static SDL_Keycode SDL_SCANCODE_TO_KEYCODE(SDL_Scancode X) { return((SDL_Keycode)((int)X | SDLK_SCANCODE_MASK)); }
/// <summary> /// 获取windowsKeyCode /// </summary> /// <param name="code"></param> /// <returns></returns> private static KeyboardCode GetWindowsKeycodeFromSDLKeycode(SDL_Scancode code) { if (code >= SDL_Scancode.SDL_SCANCODE_1 && code <= SDL_Scancode.SDL_SCANCODE_9) { return(KeyboardCode.VKEY_1 + (code - SDL_Scancode.SDL_SCANCODE_1)); } else if (code >= SDL_Scancode.SDL_SCANCODE_A && code <= SDL_Scancode.SDL_SCANCODE_Z) { return(KeyboardCode.VKEY_A + (code - SDL_Scancode.SDL_SCANCODE_A)); } else if (code >= SDL_Scancode.SDL_SCANCODE_F1 && code <= SDL_Scancode.SDL_SCANCODE_F24) { return(KeyboardCode.VKEY_F1 + (code - SDL_Scancode.SDL_SCANCODE_F1)); } switch (code) { case SDL_Scancode.SDL_SCANCODE_0: return(KeyboardCode.VKEY_9); case SDL_Scancode.SDL_SCANCODE_LSHIFT: case SDL_Scancode.SDL_SCANCODE_RSHIFT: return(KeyboardCode.VKEY_CONTROL); case SDL_Scancode.SDL_SCANCODE_LCTRL: case SDL_Scancode.SDL_SCANCODE_RCTRL: return(KeyboardCode.VKEY_CONTROL); case SDL_Scancode.SDL_SCANCODE_LALT: case SDL_Scancode.SDL_SCANCODE_RALT: return(KeyboardCode.VKEY_ALTGR); case SDL_Scancode.SDL_SCANCODE_BACKSPACE: return(KeyboardCode.VKEY_BACK); case SDL_Scancode.SDL_SCANCODE_RETURN: return(KeyboardCode.VKEY_RETURN); case SDL_Scancode.SDL_SCANCODE_HOME: return(KeyboardCode.VKEY_HOME); case SDL_Scancode.SDL_SCANCODE_INSERT: return(KeyboardCode.VKEY_INSERT); case SDL_Scancode.SDL_SCANCODE_END: return(KeyboardCode.VKEY_END); case SDL_Scancode.SDL_SCANCODE_SCROLLLOCK: return(KeyboardCode.VKEY_SCROLL); case SDL_Scancode.SDL_SCANCODE_DELETE: return(KeyboardCode.VKEY_DELETE); case SDL_Scancode.SDL_SCANCODE_TAB: return(KeyboardCode.VKEY_TAB); case SDL_Scancode.SDL_SCANCODE_SPACE: return(KeyboardCode.VKEY_SPACE); case SDL_Scancode.SDL_SCANCODE_COMMA: return(KeyboardCode.VKEY_COMMAND); case SDL_Scancode.SDL_SCANCODE_LGUI: return(KeyboardCode.VKEY_LWIN); case SDL_Scancode.SDL_SCANCODE_CAPSLOCK: return(KeyboardCode.VKEY_CAPITAL); case SDL_Scancode.SDL_SCANCODE_UP: return(KeyboardCode.VKEY_UP); case SDL_Scancode.SDL_SCANCODE_DOWN: return(KeyboardCode.VKEY_DOWN); case SDL_Scancode.SDL_SCANCODE_LEFT: return(KeyboardCode.VKEY_LEFT); case SDL_Scancode.SDL_SCANCODE_RIGHT: return(KeyboardCode.VKEY_RIGHT); case SDL_Scancode.SDL_SCANCODE_PAGEUP: return(KeyboardCode.VKEY_PRIOR); case SDL_Scancode.SDL_SCANCODE_PAGEDOWN: return(KeyboardCode.VKEY_NEXT); case SDL_Scancode.SDL_SCANCODE_EQUALS: return(KeyboardCode.VKEY_OEM_PLUS); case SDL_Scancode.SDL_SCANCODE_MINUS: return(KeyboardCode.VKEY_OEM_MINUS); default: return(KeyboardCode.VKEY_UNKNOWN); } }