Ejemplo n.º 1
0
        internal static unsafe void UnregisterWindow(WindowHandle *handle, IEnumerable <IGlfwSubscriber> subscribers)
        {
            var events = _subs.ContainsKey
                             ((nint)handle)
                ? _subs[(nint)handle]
                : _subs[(nint)handle] = new GlfwEvents(handle);

            foreach (var subscriber in subscribers)
            {
                subscriber.Unsubscribe(events);
            }
        }
Ejemplo n.º 2
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);