private void EmitKeyEvent(Keyboard.Key key, InputAction action, KeyModifiers mods) { var shift = (mods & KeyModifiers.Shift) != 0; var alt = (mods & KeyModifiers.Alt) != 0; var control = (mods & KeyModifiers.Control) != 0; var system = (mods & KeyModifiers.Super) != 0; var ev = new KeyEventArgs( key, action == InputAction.Repeat, alt, control, shift, system); switch (action) { case InputAction.Release: _gameController.KeyUp(ev); break; case InputAction.Press: case InputAction.Repeat: _gameController.KeyDown(ev); break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); } }
private void OnGlfwMouseButton(Window *window, MouseButton button, InputAction action, KeyModifiers mods) { try { EmitKeyEvent(Mouse.MouseButtonToKey(Mouse.ConvertGlfwButton(button)), action, mods); } catch (Exception e) { CatchCallbackException(e); } }
private void OnGlfwKey(Window *window, Keys key, int scanCode, InputAction action, KeyModifiers mods) { try { EmitKeyEvent(Keyboard.ConvertGlfwKey(key), action, mods); } catch (Exception e) { CatchCallbackException(e); } }