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

            foreach (var subscriber in subscribers)
            {
                subscriber.Unsubscribe(events);
            }
        }
Beispiel #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);