public unsafe void Subscribe(GlfwEvents events) { _handle = events.Handle; events.Char += _char = (_, c) => KeyChar?.Invoke(this, (char)c); events.Key += _key = (_, key, code, action, mods) => (action switch { InputAction.Press => KeyDown, InputAction.Release => KeyUp, InputAction.Repeat => null, _ => null })?.Invoke(this, ConvertKey(key), code);
public unsafe void DoEvent(Event @event) { switch ((EventType)@event.Type) { case EventType.Keydown: { if (@event.Key.Repeat != 1 && _keyMap.TryGetValue((KeyCode)@event.Key.Keysym.Sym, out var key)) { _keysDown.Add(key); KeyDown?.Invoke(this, key, (int)@event.Key.Keysym.Scancode); } break; } case EventType.Keyup: { if (@event.Key.Repeat != 1 && _keyMap.TryGetValue((KeyCode)@event.Key.Keysym.Sym, out var key)) { _keysDown.Remove(key); KeyUp?.Invoke(this, key, (int)@event.Key.Keysym.Scancode); } break; } case EventType.Textediting: { break; } case EventType.Textinput: { for (int i = 0; i < 32; i++) { var @char = @event.Text.Text[i]; if (@char == 0) { break; } KeyChar?.Invoke(this, (char)@char); } break; } case EventType.Keymapchanged: break; } }
public void FireKeyChar(KeyCharEventArgs e) { KeyChar?.Invoke(this, e); }
/// <summary> /// Raises the OnChar event. Override this method to add code to handle when a WM_CHAR message is received /// </summary> /// <param name="e">InputEventCKB for the OnChar event</param> private void invokeChar(InputEventKeyboard e) { KeyChar?.Invoke(e); }
public void RaiseCharEvent(char c) { KeyChar?.Invoke(this, c); }