private void MouseMoveTimer_Tick(object sender, EventArgs e) { var val = _thumbStickValue; val.Y = -val.Y; // todo, these two equations may actually be one? val *= 1 + (_leftTrigger_mouseSpeed - 1) * _leftTriggerValue; val *= 1 - (1 - _rightTrigger_mouseSpeed) * _rightTriggerValue; _cursorPosition += val * 20f; var screenSize = Screen.PrimaryScreen.Bounds; if (_cursorPosition.X < 0) { _cursorPosition.X = 0; } else if (_cursorPosition.X > screenSize.Width) { _cursorPosition.X = screenSize.Width; } if (_cursorPosition.Y < 0) { _cursorPosition.Y = 0; } else if (_cursorPosition.Y > screenSize.Height) { _cursorPosition.Y = screenSize.Height; } Cursor.Position = new System.Drawing.Point((int)_cursorPosition.X, (int)_cursorPosition.Y); }
public char GetChar(Input.Vector2 value) { return(_activeElement.GetChar( (int)-value.X, (int)value.Y )); }
public void SetBlockFocus(Input.Vector2 value) { if (value.GetLength() < 0.5) { value = new Input.Vector2(); } value = value.GetNormalized(); FocusBlock(_elmGrid[ (int)(value.X + 1), (int)(-value.Y + 1) ]); }
private void gamePadInput_ThumbRightChange(int player, GamePadState state, Input.Vector2 value) { _rightStickValue = value; if ((value.Y != 0 || value.X != 0) && _mouseScrollTimer.Enabled == false) { _mouseScrollTimer.Enabled = true; } else if ((value.Y == 0 && value.X == 0) && _mouseScrollTimer.Enabled == true) { _mouseScrollTimer.Enabled = false; } }
private void gamePadInput_ThumbLeftChange(int player, GamePadState state, Input.Vector2 value) { _thumbStickValue = value; if (_thumbStickValue.GetSquared() == 0d && _mouseMoveTimer.Enabled == true) { _mouseMoveTimer.Enabled = false; } if (_thumbStickValue.GetSquared() != 0d && _mouseMoveTimer.Enabled == false) { _cursorPosition = new Input.Vector2(Cursor.Position.X, Cursor.Position.Y); _mouseMoveTimer.Enabled = true; } }
public Osk(bool simulate) { InitializeComponent(); _gamePadWrapper = new GamePadWrapper(this); TextBox.Text = ""; System.Windows.Controls.Canvas.SetLeft(Caret, 0); if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)) { return; } Loaded += OnLoaded; _startSize = new Input.Vector2( Width, Height ); _keyboardInputSimulator.SimulatorKeyboard = simulate; }
private void WrapperOnBlockPosChanged(Input.Vector2 value) => Dial.SetBlockFocus(value);
private void WrapperOnCharPosChanged(Input.Vector2 value) => _keyboardInputSimulator.InsertText(Dial.GetChar(value));