public void Init(GameWindow game) { if (_game != null) { return; } _game = game; this._originalOSCursor = _game.Cursor; game.MouseDown += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseDown.InvokeAsync(new AGS.API.MouseButtonEventArgs(null, button, MousePosition))); }; game.MouseUp += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseUp.InvokeAsync(new AGS.API.MouseButtonEventArgs(null, button, MousePosition))); }; game.MouseMove += (sender, e) => { if (isInputBlocked()) { return; } _mouseX = e.Mouse.X; _mouseY = e.Mouse.Y; _actions.Enqueue(() => MouseMove.InvokeAsync(new MousePositionEventArgs(MousePosition))); }; game.KeyDown += (sender, e) => { API.Key key = convert(e.Key); _keysDown.Add(key); if (isInputBlocked()) { return; } _actions.Enqueue(() => KeyDown.InvokeAsync(new KeyboardEventArgs(key))); }; game.KeyUp += (sender, e) => { API.Key key = convert(e.Key); _keysDown.Remove(key); if (isInputBlocked()) { return; } _actions.Enqueue(() => KeyUp.InvokeAsync(new KeyboardEventArgs(key))); }; _events.OnRepeatedlyExecuteAlways.Subscribe(onRepeatedlyExecute); }
private async void onKeyUp(object sender, Tuple <Keycode, KeyEvent> args) { var key = args.Item1.Convert(); if (key == null) { return; } await KeyUp.InvokeAsync(sender, new KeyboardEventArgs(key.Value)); }
private void init(GameWindow game) { if (_game != null) { return; } _game = game; _originalOSCursor = game.Cursor; _cursor.PropertyChanged += (sender, e) => { if (_cursor.Cursor != null) { _game.Cursor = MouseCursor.Empty; } }; game.MouseDown += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseDown.InvokeAsync(new API.MouseButtonEventArgs(_hitTest.ObjectAtMousePosition, button, MousePosition))); }; game.MouseUp += (sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); _actions.Enqueue(() => MouseUp.InvokeAsync(new API.MouseButtonEventArgs(_hitTest.ObjectAtMousePosition, button, MousePosition))); }; game.MouseMove += (sender, e) => { _mouseX = e.Mouse.X; _mouseY = e.Mouse.Y; _actions.Enqueue(() => MouseMove.InvokeAsync(new MousePositionEventArgs(MousePosition))); }; game.KeyDown += (sender, e) => { API.Key key = convert(e.Key); _keysDown.Add(key); if (isInputBlocked()) { return; } _actions.Enqueue(() => KeyDown.InvokeAsync(new KeyboardEventArgs(key))); }; game.KeyUp += (sender, e) => { API.Key key = convert(e.Key); _keysDown.Remove(key); if (isInputBlocked()) { return; } _actions.Enqueue(() => KeyUp.InvokeAsync(new KeyboardEventArgs(key))); }; _events.OnRepeatedlyExecuteAlways.Subscribe(onRepeatedlyExecute); }