示例#1
0
 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);
示例#2
0
        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;
            }
        }
示例#3
0
 public void FireKeyChar(KeyCharEventArgs e)
 {
     KeyChar?.Invoke(this, e);
 }
示例#4
0
 /// <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);
 }
示例#5
0
 public void RaiseCharEvent(char c)
 {
     KeyChar?.Invoke(this, c);
 }