internal void TriggerOnKeyRepeat(Keys key, float timeDown) { OnKeyRepeat?.Invoke(key, timeDown); }
public virtual void KeyRepeat(Key key) { OnKeyRepeat?.Invoke(key); }
static void InitEvents() { Log.Info("Registering window events"); window.RenderFrame += (sender, e) => { timer.Tick(); RenderState.SetupViewport(); OnRender?.Invoke(); State?.Render(); window.SwapBuffers(); FinalizeGLResources(); }; window.UpdateFrame += (sender, e) => { OnUpdate?.Invoke(e.Time); var state = State; if (state != null) { state.Update(e.Time); if (state.Closed) { State = null; } } if (State == null) { Kill(); } }; window.KeyDown += (sender, e) => { var key = (Key)e.Key; if (e.IsRepeat) { OnKeyRepeat?.Invoke(key); State?.KeyRepeat(key); } else { OnKeyDown?.Invoke(key); State?.KeyDown(key); } if (e.Key == OpenTK.Input.Key.F4 && e.Modifiers.HasFlag(OpenTK.Input.KeyModifiers.Alt)) { window.Close(); } }; window.KeyUp += (sender, e) => { OnKeyUp?.Invoke((Key)e.Key); State?.KeyUp((Key)e.Key); }; window.KeyPress += (sender, e) => { OnCharInput?.Invoke(e.KeyChar); State?.CharInput(e.KeyChar); }; window.MouseDown += (sender, e) => { OnMouseDown?.Invoke((MouseButton)e.Button, Mouse.Position); State?.MouseDown((MouseButton)e.Button, Mouse.Position); }; window.MouseUp += (sender, e) => { OnMouseUp?.Invoke((MouseButton)e.Button, Mouse.Position); State?.MouseUp((MouseButton)e.Button, Mouse.Position); }; window.MouseMove += (sender, e) => { OnMouseMove?.Invoke(Mouse.Position); State?.MouseMove(Mouse.Position); }; window.MouseWheel += (sender, e) => { OnMouseWheel?.Invoke(e.DeltaPrecise); State?.MouseWheel(e.DeltaPrecise); }; window.Resize += (sender, e) => { OpenTK.Graphics.OpenGL.GL.Viewport(0, 0, Width, Height); }; }
protected void Invoke_OnKeyRepeat(object sender, KeyArgs args) { OnKeyRepeat?.Invoke(sender, args); }