public static string TryGetKey(SDL.SDL_Keycode key, SDL.SDL_Keymod mod = SDL.SDL_Keymod.KMOD_NONE) { if (_keys.TryGetValue(key, out string value)) { StringBuilder sb = new StringBuilder(); bool isshift = (mod & SDL.SDL_Keymod.KMOD_LSHIFT) != 0; bool isctrl = (mod & SDL.SDL_Keymod.KMOD_LCTRL) != 0; bool isalt = (mod & SDL.SDL_Keymod.KMOD_LALT) != 0; if (isshift) { sb.Append("Shift "); } if (isctrl) { sb.Append("Ctrl "); } if (isalt) { sb.Append("Alt "); } sb.Append(value); return(sb.ToString()); } return(string.Empty); }
private void SetupKeyByDefault() { if (Macro == null || _hotkeyBox == null) { return; } if (Macro.Key != SDL.SDL_Keycode.SDLK_UNKNOWN) { SDL.SDL_Keymod mod = SDL.SDL_Keymod.KMOD_NONE; if (Macro.Alt) { mod |= SDL.SDL_Keymod.KMOD_ALT; } if (Macro.Shift) { mod |= SDL.SDL_Keymod.KMOD_SHIFT; } if (Macro.Ctrl) { mod |= SDL.SDL_Keymod.KMOD_CTRL; } _hotkeyBox.SetKey(Macro.Key, mod); } }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_KP_ENTER || key == SDL.SDL_Keycode.SDLK_RETURN) { OnButtonClick((int)LoginButtons.OK); } }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_RETURN || key == SDL.SDL_Keycode.SDLK_KP_ENTER) { LoginCharacter(_selectedCharacter); } }
internal KeyAction(SDL.SDL_KeyboardEvent ev) { SDL.SDL_Keymod modifiers = ev.keysym.mod; KeyFlags cflags = KeyFlags.Null; if ((modifiers & SDL.SDL_Keymod.KMOD_SHIFT) != 0) { cflags |= KeyFlags.Shift; } if ((modifiers & SDL.SDL_Keymod.KMOD_ALT) != 0) { cflags |= KeyFlags.Alt; } if ((modifiers & SDL.SDL_Keymod.KMOD_CTRL) != 0) { cflags |= KeyFlags.Ctrl; } if ((modifiers & SDL.SDL_Keymod.KMOD_CAPS) != 0) { cflags |= KeyFlags.CapsLock; } Flags = cflags; Key = MapSDLKeycode(ev.keysym.sym); Repeat = ev.repeat != 0; }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_RETURN || key == SDL.SDL_Keycode.SDLK_KP_ENTER) { LoginScene loginScene = Client.Game.GetScene <LoginScene>(); if (loginScene.Servers.Any()) { int index = Settings.GlobalSettings.LastServerNum; if (index <= 0 || index > loginScene.Servers.Length) { Log.Warn($"Wrong server index: {index}"); index = 1; } loginScene.SelectServer ( (byte)loginScene.Servers[index - 1] .Index ); } } }
public static bool HandleEvent(SDL.SDL_Event e, ref float mouseWheel, bool[] mousePressed) { ImGuiIO io = ImGui.GetIO(); switch (e.type) { case SDL.SDL_EventType.SDL_MOUSEWHEEL: if (e.wheel.y > 0) { mouseWheel = 1; } if (e.wheel.y < 0) { mouseWheel = -1; } return(true); case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN: if (mousePressed == null) { return(true); } if (e.button.button == SDL.SDL_BUTTON_LEFT && mousePressed.Length > 0) { mousePressed[0] = true; } if (e.button.button == SDL.SDL_BUTTON_RIGHT && mousePressed.Length > 1) { mousePressed[1] = true; } if (e.button.button == SDL.SDL_BUTTON_MIDDLE && mousePressed.Length > 2) { mousePressed[2] = true; } return(true); case SDL.SDL_EventType.SDL_TEXTINPUT: unsafe { // THIS IS THE ONLY UNSAFE THING LEFT! ImGui.AddInputCharactersUTF8(e.text.text); } return(true); case SDL.SDL_EventType.SDL_KEYDOWN: case SDL.SDL_EventType.SDL_KEYUP: int key = (int)e.key.keysym.sym & ~SDL.SDLK_SCANCODE_MASK; io.KeysDown[key] = e.type == SDL.SDL_EventType.SDL_KEYDOWN; SDL.SDL_Keymod keyModState = SDL.SDL_GetModState(); io.ShiftPressed = (keyModState & SDL.SDL_Keymod.KMOD_SHIFT) != 0; io.CtrlPressed = (keyModState & SDL.SDL_Keymod.KMOD_CTRL) != 0; io.AltPressed = (keyModState & SDL.SDL_Keymod.KMOD_ALT) != 0; io.SuperPressed = (keyModState & SDL.SDL_Keymod.KMOD_GUI) != 0; return(true); } return(true); }
protected override void OnKeyUp(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { base.OnKeyUp(key, mod); if (key == SDL.SDL_Keycode.SDLK_RETURN && mod == 0) { OnButtonClick(0); } }
/// <summary> /// Event consumes return key for textbox input (name change) /// </summary> /// <param name="key"></param> /// <param name="mod"></param> protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_RETURN && _textboxName.IsEditable) { GameActions.Rename(Mobile, _textboxName.Text); _textboxName.IsEditable = false; UIManager.KeyboardFocusControl = null; } base.OnKeyDown(key, mod); }
public MacroControl(string name) { CanMove = true; HotkeyBox box = new HotkeyBox(); box.HotkeyChanged += BoxOnHotkeyChanged; box.HotkeyCancelled += BoxOnHotkeyCancelled; Add(box); Add(new NiceButton(0, box.Height + 3, 170, 25, ButtonAction.Activate, "+ Create macro button", 0, IO.Resources.TEXT_ALIGN_TYPE.TS_LEFT) { ButtonParameter = 2, IsSelectable = false }); Add(new NiceButton(0, box.Height + 30, 50, 25, ButtonAction.Activate, "Add") { IsSelectable = false }); Add(new NiceButton(52, box.Height + 30, 50, 25, ButtonAction.Activate, "Remove") { ButtonParameter = 1, IsSelectable = false }); Add(_collection = new MacroCollectionControl(name, 280, 280) { Y = box.Height + 50 + 10 }); if (_collection.Macro.Key != SDL.SDL_Keycode.SDLK_UNKNOWN) { SDL.SDL_Keymod mod = SDL.SDL_Keymod.KMOD_NONE; if (_collection.Macro.Alt) { mod |= SDL.SDL_Keymod.KMOD_ALT; } if (_collection.Macro.Shift) { mod |= SDL.SDL_Keymod.KMOD_SHIFT; } if (_collection.Macro.Ctrl) { mod |= SDL.SDL_Keymod.KMOD_CTRL; } box.SetKey(_collection.Macro.Key, mod); } }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_RETURN || key == SDL.SDL_Keycode.SDLK_KP_ENTER) { LoginScene loginScene = Engine.SceneManager.GetScene <LoginScene>(); if (loginScene.Servers.Any()) { loginScene.SelectServer((byte)loginScene.Servers[(Engine.GlobalSettings.LastServerNum - 1)].Index); } } }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (Mobile == null) { return; } if ((key == SDL.SDL_Keycode.SDLK_RETURN || key == SDL.SDL_Keycode.SDLK_KP_ENTER) && _textBox.IsEditable) { GameActions.Rename(Mobile, _textBox.Text); _textBox.IsEditable = false; } }
public KeyboardState( SDL.SDL_Keymod modifier, SDL.SDL_Scancode key, bool repeat, KeyState state, uint timestamp, SDL.SDL_EventType type) { Modifier = modifier; Key = key; Repeat = repeat; State = state; Timestamp = timestamp; Type = type; }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_RETURN || key == SDL.SDL_Keycode.SDLK_KP_ENTER) { LoginScene loginScene = Client.Game.GetScene <LoginScene>(); if (loginScene.Servers.Any()) { int index = loginScene.GetServerIndexFromSettings(); loginScene.SelectServer((byte)loginScene.Servers[index].Index); } } }
public MacroControl(string name) { CanMove = true; HotkeyBox box = new HotkeyBox(); box.HotkeyChanged += BoxOnHotkeyChanged; box.HotkeyCancelled += BoxOnHotkeyCancelled; Add(box); Add(new NiceButton(0, box.Height + 3, 50, 25, ButtonAction.Activate, "Add") { IsSelectable = false }); Add(new NiceButton(52, box.Height + 3, 50, 25, ButtonAction.Activate, "Remove") { ToPage = 1, IsSelectable = false }); Add(_collection = new MacroCollectionControl(name, 280, 280) { Y = box.Height + 25 + 10 }); if (_collection.Macro.Key != SDL.SDL_Keycode.SDLK_UNKNOWN) { SDL.SDL_Keymod mod = SDL.SDL_Keymod.KMOD_NONE; if (_collection.Macro.Alt) { mod |= SDL.SDL_Keymod.KMOD_LALT; } if (_collection.Macro.Shift) { mod |= SDL.SDL_Keymod.KMOD_LSHIFT; } if (_collection.Macro.Ctrl) { mod |= SDL.SDL_Keymod.KMOD_LCTRL; } box.SetKey(_collection.Macro.Key, mod); } }
// Unfortunately, SDL does not report KeyDown events // when a modifier (e.g. shift, alt, etc) is first pressed. // It reports a keydown+keyup event pair when the modifier // is *released* - which means that we cannot use modifiers // for regular input (e.g. press control to fire a weapon.) // For that reason, we should also poll the keyboard directly // as necessary. // Fixme: this does not appear to work as expected. void UpdateModifiers() { SDL.SDL_Keymod mod = SDL.SDL_GetModState(); state.SetKeyState(Key.LAlt, (byte)SDL.SDL_Scancode.SDL_SCANCODE_LALT, (mod & SDL.SDL_Keymod.KMOD_LALT) != 0); state.SetKeyState(Key.RAlt, (byte)SDL.SDL_Scancode.SDL_SCANCODE_RALT, (mod & SDL.SDL_Keymod.KMOD_RALT) != 0); state.SetKeyState(Key.LControl, (byte)SDL.SDL_Scancode.SDL_SCANCODE_LCTRL, (mod & SDL.SDL_Keymod.KMOD_LCTRL) != 0); state.SetKeyState(Key.RControl, (byte)SDL.SDL_Scancode.SDL_SCANCODE_RCTRL, (mod & SDL.SDL_Keymod.KMOD_RCTRL) != 0); state.SetKeyState(Key.LShift, (byte)SDL.SDL_Scancode.SDL_SCANCODE_LSHIFT, (mod & SDL.SDL_Keymod.KMOD_LSHIFT) != 0); state.SetKeyState(Key.RShift, (byte)SDL.SDL_Scancode.SDL_SCANCODE_RSHIFT, (mod & SDL.SDL_Keymod.KMOD_RSHIFT) != 0); state.SetKeyState(Key.Menu, (byte)SDL.SDL_Scancode.SDL_SCANCODE_APPLICATION, (mod & SDL.SDL_Keymod.KMOD_GUI) != 0); state.SetKeyState(Key.CapsLock, (byte)SDL.SDL_Scancode.SDL_SCANCODE_CAPSLOCK, (mod & SDL.SDL_Keymod.KMOD_CAPS) != 0); state.SetKeyState(Key.NumLock, (byte)SDL.SDL_Scancode.SDL_SCANCODE_NUMLOCKCLEAR, (mod & SDL.SDL_Keymod.KMOD_NUM) != 0); //state.SetKeyState(Key., (byte)SDL.SDL_Scancode.SDL_SCANCODE_MODE, (mod & SDL.SDL_Keymod.KMOD_MODE) != 0); }
//public static bool IsKeyPressed(SDL.SDL_Keycode code) //{ // return code != SDL.SDL_Keycode.SDLK_UNKNOWN && _code == code; //} //public static bool IsModPressed(SDL.SDL_Keymod mod, SDL.SDL_Keymod tocheck) //{ // mod ^= mod & IgnoreKeyMod; // return tocheck == mod || mod != SDL.SDL_Keymod.KMOD_NONE && (mod & tocheck) != 0; //} public static void OnKeyUp(SDL.SDL_KeyboardEvent e) { SDL.SDL_Keymod mod = e.keysym.mod & ~IgnoreKeyMod; if ((mod & (SDL.SDL_Keymod.KMOD_RALT | SDL.SDL_Keymod.KMOD_LCTRL)) == (SDL.SDL_Keymod.KMOD_RALT | SDL.SDL_Keymod.KMOD_LCTRL)) { e.keysym.sym = SDL.SDL_Keycode.SDLK_UNKNOWN; e.keysym.mod = SDL.SDL_Keymod.KMOD_NONE; } Shift = (e.keysym.mod & SDL.SDL_Keymod.KMOD_SHIFT) != SDL.SDL_Keymod.KMOD_NONE; Alt = (e.keysym.mod & SDL.SDL_Keymod.KMOD_ALT) != SDL.SDL_Keymod.KMOD_NONE; Ctrl = (e.keysym.mod & SDL.SDL_Keymod.KMOD_CTRL) != SDL.SDL_Keymod.KMOD_NONE; _code = SDL.SDL_Keycode.SDLK_UNKNOWN; }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { if (key == SDL.SDL_Keycode.SDLK_DELETE) { for (int i = 0; i < _boxes.Count; i++) { var box = _boxes[i]; if (box.IsEditing) { if (i == 0) { Engine.UI.Add(new MessageBoxGump(200, 150, "Cannot delete this group.", null)); break; } if (SkillsGroupManager.RemoveGroup(box.LabelText)) { foreach (var child in box.FindControls <SkillControl>()) { _boxes[0].AddItem(child); } _boxes[0].Items.Sort((a, b) => { var s0 = (SkillControl)a; var s1 = (SkillControl)b; var skill0 = World.Player.Skills[s0.SkillIndex]; var skill1 = World.Player.Skills[s1.SkillIndex]; return(skill0.Name.CompareTo(skill1.Name)); }); _boxes[0].GenerateButtons(); box.Children.Clear(); _container.Remove(box); _boxes.RemoveAt(i); } break; } } } }
public bool Bind(HotkeyAction action, SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { foreach (HotKeyCombination h in _hotkeys) { if (h.Key == key && h.Mod == mod) { return(false); } } _hotkeys.Add(new HotKeyCombination { Key = key, Mod = mod, KeyAction = action }); return(true); }
private static ModifierKeys MapModifierKeys(SDL.SDL_Keymod mod) { ModifierKeys mods = ModifierKeys.None; if ((mod & (SDL.SDL_Keymod.KMOD_LSHIFT | SDL.SDL_Keymod.KMOD_RSHIFT)) != 0) { mods |= ModifierKeys.Shift; } if ((mod & (SDL.SDL_Keymod.KMOD_LALT | SDL.SDL_Keymod.KMOD_RALT)) != 0) { mods |= ModifierKeys.Alt; } if ((mod & (SDL.SDL_Keymod.KMOD_LCTRL | SDL.SDL_Keymod.KMOD_RCTRL)) != 0) { mods |= ModifierKeys.Control; } return(mods); }
public bool TryExecuteIfBinded(SDL.SDL_Keycode key, SDL.SDL_Keymod mod, out Action action) { for (int i = 0; i < _hotkeys.Count; i++) { var h = _hotkeys[i]; if (h.Key == key && h.Mod == mod) { if (_actions.TryGetValue(h.KeyAction, out action)) { return(true); } break; } } action = null; return(false); }
public bool Bind(HotkeyAction action, SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { for (int i = 0; i < _hotkeys.Count; i++) { var h = _hotkeys[i]; if (h.Key == key && h.Mod == mod) { return(false); } } _hotkeys.Add(new HotKeyCombination() { Key = key, Mod = mod, KeyAction = action }); return(true); }
public static KeyModifiers MapSdlMods(SDL.SDL_Keymod mods) { if (mods == SDL.SDL_Keymod.KMOD_NONE) { return(KeyModifiers.None); } KeyModifiers result = KeyModifiers.None; if ((mods & SDL.SDL_Keymod.KMOD_LCTRL) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.LeftControl; } if ((mods & SDL.SDL_Keymod.KMOD_LALT) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.LeftAlt; } if ((mods & SDL.SDL_Keymod.KMOD_LSHIFT) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.LeftShift; } if ((mods & SDL.SDL_Keymod.KMOD_RCTRL) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.RightControl; } if ((mods & SDL.SDL_Keymod.KMOD_RALT) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.RightAlt; } if ((mods & SDL.SDL_Keymod.KMOD_RSHIFT) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.RightShift; } if ((mods & SDL.SDL_Keymod.KMOD_CAPS) != SDL.SDL_Keymod.KMOD_NONE) { result |= KeyModifiers.Caps; } return(result); }
public InputMouseEvent(MouseEvent type, MouseButton button, int clicks, int x, int y, int data, SDL.SDL_Keymod mod) : base(mod) { EventType = type; Button = button; _clicks = clicks; X = x; Y = y; _data = data; }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { int curpage = ActiveInternalPage; var box = curpage >= 0 ? m_Pages[curpage] : null; var entry = box?.TxEntry; if (key == SDL.SDL_Keycode.SDLK_BACKSPACE || key == SDL.SDL_Keycode.SDLK_DELETE) { if (curpage >= 0) { if (curpage > 0) { if (key == SDL.SDL_Keycode.SDLK_BACKSPACE) { if (_AtEnd < 0) { if ((curpage + 1) % 2 == 0) { SetActivePage(ActivePage - 1); } curpage--; box = m_Pages[curpage]; entry = box.TxEntry; RefreshShowCaretPos(entry.Text.Length, box); _AtEnd = 1; } else if (entry != null && entry.CaretIndex == 0) { _AtEnd = -1; } } else { _AtEnd = (sbyte)(entry != null && entry.CaretIndex == 0 ? -1 : entry.CaretIndex + 1 >= entry.Text.Length && curpage < BookPageCount ? 1 : 0); } } else { _AtEnd = 0; } if (!_scale) { _AtEnd = 0; return; } _scale = false; if (entry != null) { int caretpos = entry.CaretIndex, active = curpage; curpage++; if (curpage < BookPageCount) //if we are on the last page it doesn't need the front text backscaling { StringBuilder sb = new StringBuilder(); do { entry = m_Pages[curpage].TxEntry; box = m_Pages[curpage]; int curlen = entry.Text.Length, prevlen = m_Pages[curpage - 1].Text.Length, chonline = box.GetCharsOnLine(0), prevpage = curpage - 1; m_Pages[prevpage].TxEntry.SetCaretPosition(prevlen); for (int i = MaxBookLines - m_Pages[prevpage].LinesCount; i > 0 && prevlen > 0; --i) { sb.Append('\n'); } sb.Append(entry.Text.Substring(0, chonline)); if (curlen > 0) { sb.Append('\n'); entry.Text = entry.Text.Substring(chonline); } m_Pages[prevpage].TxEntry.InsertString(sb.ToString()); curpage++; sb.Clear(); } while (curpage < BookPageCount); m_Pages[active].TxEntry.SetCaretPosition(caretpos); } } } } else if (key == SDL.SDL_Keycode.SDLK_RIGHT) { if (curpage >= 0 && curpage + 1 < BookPageCount) { if (entry != null && entry.CaretIndex + 1 >= box.Text.Length) { if (_AtEnd > 0) { if ((curpage + 1) % 2 == 1) { SetActivePage(ActivePage + 1); } RefreshShowCaretPos(0, m_Pages[curpage + 1]); _AtEnd = -1; } else { _AtEnd = 1; } return; } } _AtEnd = 0; } else if (key == SDL.SDL_Keycode.SDLK_LEFT) { if (curpage > 0) { if (entry != null && entry.CaretIndex == 0) { if (_AtEnd < 0) { if ((curpage + 1) % 2 == 0) { SetActivePage(ActivePage - 1); } RefreshShowCaretPos(m_Pages[curpage - 1].Text.Length, m_Pages[curpage - 1]); _AtEnd = 1; } else { _AtEnd = -1; } return; } } _AtEnd = 0; } else if (key == SDL.SDL_Keycode.SDLK_UP) { if (curpage > 0) { if (entry != null && entry.CaretIndex == 0) { if (_AtEnd < 0) { if ((curpage + 1) % 2 == 0) { SetActivePage(ActivePage - 1); } RefreshShowCaretPos(m_Pages[curpage - 1].Text.Length, m_Pages[curpage - 1]); _AtEnd = 1; } else { _AtEnd = -1; } return; } } _AtEnd = 0; } else if (key == SDL.SDL_Keycode.SDLK_DOWN) { if (curpage + 1 < BookPageCount && curpage >= 0) { if (entry != null && entry.CaretIndex + 1 >= box.Text.Length) { if (_AtEnd > 0) { if ((curpage + 1) % 2 == 1) { SetActivePage(ActivePage + 1); } RefreshShowCaretPos(0, m_Pages[curpage + 1]); _AtEnd = -1; } else { _AtEnd = 1; } return; } } _AtEnd = 0; } else if (key == SDL.SDL_Keycode.SDLK_HOME) { if (curpage > 0) { if (_AtEnd < 0) { if ((curpage + 1) % 2 == 0) { SetActivePage(ActivePage - 1); } RefreshShowCaretPos(m_Pages[curpage - 1].Text.Length, m_Pages[curpage - 1]); _AtEnd = 1; return; } } _AtEnd = 0; } else if (key == SDL.SDL_Keycode.SDLK_END) { if (curpage >= 0 && curpage + 1 < BookPageCount) { if (_AtEnd > 0) { if ((curpage + 1) % 2 == 1) { SetActivePage(ActivePage + 1); } RefreshShowCaretPos(0, m_Pages[curpage + 1]); _AtEnd = -1; return; } } _AtEnd = 0; } else { _AtEnd = 0; } }
protected override void OnKeyDown(SDL.SDL_Keycode key, SDL.SDL_Keymod mod) { base.OnKeyDown(key, mod); UpdateCaretScreenPosition(); }
public static bool IsModPressed(SDL.SDL_Keymod mod, SDL.SDL_Keymod tocheck) { mod ^= mod & IgnoreKeyMod; return(tocheck == mod || (mod != SDL.SDL_Keymod.KMOD_NONE && (mod & tocheck) != 0)); }
public void HandleEvent(ref SDL.SDL_Event e) { switch (e.type) { case SDL.SDL_EventType.SDL_TEXTINPUT: { // Typed text if (m_window.Focus) { byte[] bytes = new byte[SDL.SDL_TEXTINPUTEVENT_TEXT_SIZE]; int length = 0; unsafe { fixed(byte *charPtr = e.text.text) { for (int i = 0; i < bytes.Length; ++i) { bytes[i] = charPtr[i]; if (bytes[i] == 0) { length = i; break; } } } } foreach (char c in Encoding.UTF8.GetString(bytes, 0, length)) { if (!Char.IsControl(c)) { m_pendingText.Append(c); } } } break; } case SDL.SDL_EventType.SDL_KEYDOWN: { if (m_window.Focus) { if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_v) { // Pasted text SDL.SDL_Keymod pasteModifier = (SDL.SDL_GetPlatform() == "Mac OS X") ? SDL.SDL_Keymod.KMOD_GUI : SDL.SDL_Keymod.KMOD_CTRL; if (((int)e.key.keysym.mod & (int)pasteModifier) != 0) { m_pendingText.Append(SDL.SDL_GetClipboardText()); } } if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_BACKSPACE) { // Backspace m_pendingText.Append('\b'); } if (e.key.repeat != 0) { // Key repeats var keycode = e.key.keysym.sym; var key = (Key)keycode; if (Enum.IsDefined(typeof(Key), key)) { var button = (SimpleButton)m_keys[key]; button.Repeat(); } } } break; } } }
public KeyInformation(SDL.SDL_Scancode physicalKey, SDL.SDL_Keycode virtualKey, SDL.SDL_Keymod modifier) { PhysicalKey = (PhysicalKeyCode)physicalKey; VirtualKey = (VirtualKeyCode)virtualKey; Modifier = (KeyModifier)modifier; }