public Task ParseMessageReceived(WebSocketReceiveResult result) { string messageReceived = Encoding.Default.GetString(new ArraySegment <byte>(buffer, 0, result.Count)); VirtualMouse.MouseCommand mc = VirtualMouse.JsonToMouseCommand(messageReceived); //Console.WriteLine("Parsing Command: " + mc); if (mc.command == "move") { mouse.Move(mc.x, mc.y); } else if (mc.command == "right_click") { mouse.RightClick(); } else if (mc.command == "left_click") { mouse.LeftClick(); } else if (mc.command == "left_down") { mouse.LeftDown(); } else if (mc.command == "left_up") { mouse.LeftUp(); } else if (mc.command == "right_down") { mouse.RightDown(); } else if (mc.command == "right_up") { mouse.RightUp(); } else if (mc.command == "touchpad_start") { mouse.TouchpadStart(mc.x, mc.y); } else if (mc.command == "touchpad_move") { mouse.TouchpadMove(mc.x, mc.y, (int)mc.extra); } else if (mc.command == "set_volume") { audio.SetVolume(mc.x); } else { return(Error()); } return(Success()); }
public override bool Execute(ref ControllerState state) { if (base.Execute(ref state)) { #region Mouse Buttons if (commandState == ButtonState.Down) { if (mouseButton == MouseButtons.Left) { VirtualMouse.LeftDown(); } else if (mouseButton == MouseButtons.Right) { VirtualMouse.RightDown(); } } else { if (mouseButton == MouseButtons.Left) { VirtualMouse.LeftUp(); } else if (mouseButton == MouseButtons.Right) { VirtualMouse.RightUp(); } } #endregion return(true); } else { return(false); } }
internal void Execute(ref ControllerState state) { #region State Changes if (stateChange != null) { if (stateChange.toggle) { if (state.inputMode == InputMode.Move) { state.inputMode = InputMode.Pointer; } else if (state.inputMode == InputMode.Pointer) { state.inputMode = InputMode.Move; } } else if (stateChange.newMode != InputMode.None) { state.inputMode = stateChange.newMode; } } #endregion #region Mouse Movements if (mouseMove != null) { if (mouseMove.commandTarget == CommandTarget.Cursor) { if (mouseMove.moveType == MouseMoveType.Absolute) { state.cursorPosition.X = state.centerPosition.X + (int)(state.pointCommandValue.X * mouseMove.moveScale.X); state.cursorPosition.Y = state.centerPosition.Y + (int)(state.pointCommandValue.Y * mouseMove.moveScale.Y); } } } if (target == CommandTarget.TargetReticule) { VirtualMouse.MoveAbsolute(state.targetingReticulePosition.X, state.targetingReticulePosition.Y); } else if (target == CommandTarget.Cursor) { VirtualMouse.MoveAbsolute(state.cursorPosition.X, state.cursorPosition.Y); } else { // } #endregion #region Keys if (key.HasValue) { if (commandState == KeyboardMouseCommandState.Down) { VirtualKeyboard.KeyDown(key.Value); } else { VirtualKeyboard.KeyUp(key.Value); } } #endregion #region Mouse Buttons if (mouseButton.HasValue) { if (commandState == KeyboardMouseCommandState.Down) { if (mouseButton.Value == MouseButtons.Left) { VirtualMouse.LeftDown(); } else if (mouseButton.Value == MouseButtons.Right) { VirtualMouse.RightDown(); } } else { if (mouseButton.Value == MouseButtons.Left) { VirtualMouse.LeftUp(); } else if (mouseButton.Value == MouseButtons.Right) { VirtualMouse.RightUp(); } } } #endregion }