private void HandleClick(MouseClickType clickType) { if (OnViewClicked != null) { OnViewClicked(clickType); } }
public MouseClickEvent(string processName, int x, int y, MouseButton clickedButtons, MouseButtonState buttonState, MouseClickType clickType, DateTime time) : base(processName, x, y, time) { Buttons = clickedButtons; ButtonState = buttonState; ClickType = clickType; }
/// <summary> /// 鼠标操作 /// </summary> /// <param name="ClickType"></param> public static void MouseClick(MouseClickType ClickType) { switch (ClickType) { case MouseClickType.LeftClick: SendData.mouse_event(SendData.MOUSEEVENTF_LEFTDOWN | SendData.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; case MouseClickType.RightClick: SendData.mouse_event(SendData.MOUSEEVENTF_RIGHTDOWN | SendData.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); break; case MouseClickType.LongLeftClick: SendData.mouse_event(SendData.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); break; case MouseClickType.LeftPress: SendData.mouse_event(SendData.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); break; case MouseClickType.LeftRelease: SendData.mouse_event(SendData.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; } }
public void SendMouseClick(MouseClickType type) { if (state != State.ACTIVE) { return; } try { byte[] msg = null; switch (type) { case MouseClickType.LEFT_DOWN: msg = TipoComandoBytes.CLICK_LEFT_DOWN; break; case MouseClickType.LEFT_UP: msg = TipoComandoBytes.CLICK_LEFT_UP; break; case MouseClickType.MIDDLE_DOWN: msg = TipoComandoBytes.CLICK_MIDDLE_DOWN; break; case MouseClickType.MIDDLE_UP: msg = TipoComandoBytes.CLICK_MIDDLE_UP; break; case MouseClickType.RIGHT_DOWN: msg = TipoComandoBytes.CLICK_RIGHT_DOWN; break; case MouseClickType.RIGHT_UP: msg = TipoComandoBytes.CLICK_RIGHT_UP; break; } WriteMessageMouse(msg); } catch (NetworkException) { Trace.TraceError("NetworkException in SendMouseClick()."); state = State.CLOSED_ERROR_NETWORK; controlConnectionWorker.CancelAsync(); } catch (Exception se) { Trace.TraceError("Exception in SendMouseClick(). Stack trace:\n{0}\n", se.StackTrace); if (se is IOException || se is SocketException) { state = State.CLOSED_ERROR_SERVER; controlConnectionWorker.CancelAsync(); } else { state = State.CLOSED_ERROR_SERVER; controlConnectionWorker.CancelAsync(); } } }
private void MouseDblClickEventHook(object sender, MouseEventExtArgs e) { System.Windows.Forms.MouseButtons clickedButton = e.Button; MouseClickType clickedType = (MouseClickType)e.Clicks; this.ModelItem.Properties["MouseButton"].SetValue(clickedButton); this.ModelItem.Properties["MouseClickAction"].SetValue(clickedType); MouseHook.stop(); }
public static void MouseClick(MouseClickType clickType, int xMousePosition, int yMousePosition) { switch (clickType) { case MouseClickType.DoubleLeft: mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTDOWN, xMousePosition, yMousePosition, 0, 0); mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTUP, xMousePosition, yMousePosition, 0, 0); mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTDOWN, xMousePosition, yMousePosition, 0, 0); mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTUP, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.Left: mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTDOWN, xMousePosition, yMousePosition, 0, 0); mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTUP, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.Right: mouse_event((int)MouseEvents.MOUSEEVENTF_RIGHTDOWN, xMousePosition, yMousePosition, 0, 0); mouse_event((int)MouseEvents.MOUSEEVENTF_RIGHTUP, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.Middle: mouse_event((int)MouseEvents.MOUSEEVENTF_MIDDLEDOWN, xMousePosition, yMousePosition, 0, 0); mouse_event((int)MouseEvents.MOUSEEVENTF_MIDDLEUP, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.LeftDown: mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTDOWN, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.RightDown: mouse_event((int)MouseEvents.MOUSEEVENTF_RIGHTDOWN, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.MiddleDown: mouse_event((int)MouseEvents.MOUSEEVENTF_MIDDLEDOWN, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.LeftUp: mouse_event((int)MouseEvents.MOUSEEVENTF_LEFTUP, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.RightUp: mouse_event((int)MouseEvents.MOUSEEVENTF_RIGHTUP, xMousePosition, yMousePosition, 0, 0); break; case MouseClickType.MiddleUp: mouse_event((int)MouseEvents.MOUSEEVENTF_MIDDLEUP, xMousePosition, yMousePosition, 0, 0); break; default: break; } }
private void Selection(MouseClickType mouseClickType) { if (_treeModify) { return; } _treeModify = true; if (mouseClickType == MouseClickType.RightClick) { // Sets the parent of the current BlockReference as current. model1.Entities.SetParentAsCurrent(); } else { // Deselects the previously selected item if (lastSelectedItem != null) { lastSelectedItem.Select(model1, false); lastSelectedItem = null; } var item = model1.GetItemUnderMouseCursor(_mouseLocation); if (item != null) { lastSelectedItem = item; TreeViewUtility.CleanCurrent(model1, false); // Marks as selected the entity under the mouse cursor. item.Select(model1, true); } else { // Back to the root level if (mouseClickType == MouseClickType.LeftDoubleClick) { TreeViewUtility.CleanCurrent(model1); } } } // An entity in the viewport was selected, so we highlight the corresponding element in the treeview as well TreeViewUtility.SynchScreenSelection(treeView1, new Stack <BlockReference>(model1.Entities.Parents), lastSelectedItem); model1.Invalidate(); _treeModify = false; }
private void MouseClickEventHook(object sender, MouseEventExtArgs e) { Debug.WriteLine("MouseClickEventHook"); System.Windows.Forms.MouseButtons clickedButton = e.Button; MouseClickType clickedType = (MouseClickType)e.Clicks; this.ModelItem.Properties["MouseButton"].SetValue(clickedButton); this.ModelItem.Properties["MouseClickAction"].SetValue(clickedType); if (MouseHook.Element != null) { SetElementInfo(); } }
public static byte[] GetMouseClickPackage(MouseClickType clickType, int x, int y) { MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); writer.Write((int)PackageType.MouseClick); writer.Write((int)clickType); writer.Write(x); writer.Write(y); writer.Flush(); byte[] res = stream.ToArray(); writer.Close(); stream.Close(); return(res); }
public void OnPointerUp(PointerEventData eventData) { MouseClickType clickType = eventData.button switch { PointerEventData.InputButton.Left => MouseClickType.Left, PointerEventData.InputButton.Right => MouseClickType.Right, PointerEventData.InputButton.Middle => MouseClickType.Middle, _ => throw new ArgumentOutOfRangeException() }; if (GetMousePosition(out Vector2 pos)) { browserClient.SendMouseClick(pos, eventData.clickCount, clickType, MouseEventType.Up); } }
void IConnection.SendMouseClick(MouseClickType type) { if (!started) { throw new InvalidOperationException("Connessione non è stata ancora avviata. Chiamata Start() non effetuata"); } ServerConnection currentServer = null; if (serverAttivoIndex < 0) { Trace.TraceWarning("ServerAttivoIndex è minore di 0. Index:{0}. In SendMouseClick() ", serverAttivoIndex); return; } currentServer = serverConnessi[serverAttivoIndex]; currentServer.SendMouseClick(type); }
/// <summary> /// NetMessage handler /// </summary> /// <param name="message"></param> public override void HandleNetworkMessage(IncomingEntityComponentMessage message, NetConnection client) { if (message.ComponentFamily == ComponentFamily.Click) { var type = (ComponentMessageType)message.MessageParameters[0]; var uid = (int)message.MessageParameters[1]; var mouseClickType = MouseClickType.None; if (type == ComponentMessageType.LeftClick || type == ComponentMessageType.RightClick || type == ComponentMessageType.ClickedInHand) { Owner.SendMessage(this, type, uid); mouseClickType = MouseClickType.ConvertComponentMessageTypeToClickType(type); } Owner.RaiseEvent(new ClickedOnEntityEventArgs { Clicked = Owner.Uid, Clicker = uid, MouseButton = mouseClickType }); } }
public static void Click(MouseClickType t, AutomationElement iae, int x = 0, int y = 0) { int handle = 0; try { handle = iae.Current.NativeWindowHandle; } catch { } if (x == 0 && y == 0) { try { Rect tr_point = iae.Current.BoundingRectangle; x = (int)(tr_point.Right - tr_point.Left) / 2; y = (int)(tr_point.Bottom - tr_point.Top) / 2; } catch { } } if (handle != 0) { KeyInput.Click(t, handle, x, y); } else { //using Point to click try { Point p = new Point(); Rect tr = iae.Current.BoundingRectangle; p.X = (int)tr.Left + x; p.Y = (int)tr.Top + y; KeyInput.Click(t, p); return; } catch { } } }
public void WorldObjectClicked(IWorldObjectView worldObject, MouseClickType clickType) { if (_selectedView != null) { _selectedView.SetSelected(false); _selectedView = null; } IWorldObjectModel model = null; if (worldObject != null) { model = worldObject.Model; _selectedView = worldObject; _selectedView.SetSelected(true); } if (WorldObjectSelectedEventHandler != null) { WorldObjectSelectedEventHandler(this, new WorldObjectSelectedEventArgs(model, clickType)); } }
public static void Click(MouseClickType t, int hwnd, int x = 0, int y = 0) { if (hwnd != 0) { Point Location = GetLocation(hwnd); MoveCursor(Location.X + x, Location.Y + y); } switch (t) { case MouseClickType.LClick: { ClickLeftButton(); break; } case MouseClickType.RClick: { ClickRightButton(); break; } case MouseClickType.LDClick: { ClickLeftButton(); ClickLeftButton(); break; } case MouseClickType.RDClcik: { ClickRightButton(); ClickRightButton(); break; } } }
public static void Click(MouseClickType t, Point location) { if (!IsEmpty(location)) { MoveCursor(location.X, location.Y); } switch (t) { case MouseClickType.LClick: { ClickLeftButton(); break; } case MouseClickType.RClick: { ClickRightButton(); break; } case MouseClickType.LDClick: { ClickLeftButton(); ClickLeftButton(); break; } case MouseClickType.RDClcik: { ClickRightButton(); ClickRightButton(); break; } } }
void OnClick(MouseClickType type) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity); if (hit) { var click = hit.transform.GetComponent <IClickable>(); switch (type) { case MouseClickType.Left: click?.OnLeftClick(); break; case MouseClickType.Right: click?.OnRightClick(); break; case MouseClickType.Middle: click?.OnMiddleClick(); break; } } }
public void DispatchClick(int userUID, int clickType) { Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, MouseClickType.ConvertClickTypeToComponentMessageType(clickType), userUID); }
private void SendMouseMessage(MouseClickType type, int x, int y) { byte[] data = DataProtocol.GetMouseClickPackage(type, x, y); byte[] sendData = DataProtocol.MakePackage(data); m_client.SendData(sendData); }
public ImageArgs(Control control, OperationAction action, MouseClickType clickType) { Control = control; Action = action; MouseClickType = clickType; }
public DiscreteClick(MouseClickType type, bool clickDown) { Type = type; Down = clickDown; }
public void UpdateInput(Main game, float elapsed) { if (game == null) { return; } var requestCameraDirChange = RequestDirectionChange; if (requestCameraDirChange != 0) { RotateCameraOrbit(-requestCameraDirChange, 0, 1); Vector3 orbitOriginOffsetFromModel = (OrbitCamCenter - ModelCenter_ForOrbitCam); orbitOriginOffsetFromModel = Vector3.Transform(orbitOriginOffsetFromModel, Matrix.CreateRotationY(-requestCameraDirChange)); OrbitCamCenter = (ModelCenter_ForOrbitCam + orbitOriginOffsetFromModel); CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP, MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP); OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.Forward, CameraTransform.RotationMatrixXYZ * Matrix.CreateRotationY(MathHelper.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * (OrbitCamDistance * OrbitCamDistance))); RequestDirectionChange -= requestCameraDirChange; } //if (DisableAllInput) //{ // oldWheel = GlobalInputState.Mouse.ScrollWheelValue; // return; //} // Kinda lazy but I really don't wanna go replace instances of gameTime and shit //gameTime = new GameTime(Main.MeasuredTotalTime, Main.MeasuredElapsedTime); //if (GFX.TestLightSpin) //{ // LightRotation.Y += MathHelper.PiOver4 * (float)gameTime.ElapsedGameTime.TotalSeconds; // LightRotation.X += MathHelper.PiOver4 * (float)gameTime.ElapsedGameTime.TotalSeconds; //} var gamepad = DBG.EnableGamePadInput ? GlobalInputState.GamePad1 : DBG.DisabledGamePadState; MouseState mouse = DBG.EnableMouseInput ? GlobalInputState.Mouse : DBG.DisabledMouseState; //TODO: Figure out what I was thinking here?? float clampedLerpF = 1;// MathHelper.Clamp(30 * elapsed, 0, 1); mousePos = new Vector2(MathHelper.Lerp(oldMouse.X, mouse.X, clampedLerpF), MathHelper.Lerp(oldMouse.Y, mouse.Y, clampedLerpF)); KeyboardState keyboard = DBG.EnableKeyboardInput ? GlobalInputState.Keyboard : DBG.DisabledKeyboardState; int currentWheel = mouse.ScrollWheelValue; if (DisableAllInput || OSD.Focused) { oldMouseClickL = false; oldMouseClickM = false; oldMouseClickR = false; if (mousePos.X != oldMouse.X || mousePos.Y != oldMouse.Y) { OSD.CancelTooltip(); } oldMouse = mousePos; oldClickType = MouseClickType.None; oldWheel = currentWheel; oldResetKeyPressed = false; oldOrbitCamToggleKeyPressed = false; return; } bool mouseInWindow = Main.Active && mousePos.X >= game.ClientBounds.Left && mousePos.X <game.ClientBounds.Right && mousePos.Y> game.ClientBounds.Top && mousePos.Y < game.ClientBounds.Bottom; currentClickType = MouseClickType.None; if (mouse.LeftButton == ButtonState.Pressed) { currentClickType = MouseClickType.Left; } else if (mouse.RightButton == ButtonState.Pressed) { currentClickType = MouseClickType.Right; } else if (mouse.MiddleButton == ButtonState.Pressed) { currentClickType = MouseClickType.Middle; } else if (mouse.XButton1 == ButtonState.Pressed) { currentClickType = MouseClickType.Extra1; } else if (mouse.XButton2 == ButtonState.Pressed) { currentClickType = MouseClickType.Extra2; } else { currentClickType = MouseClickType.None; } currentMouseClickL = currentClickType == MouseClickType.Left; currentMouseClickR = currentClickType == MouseClickType.Right; currentMouseClickM = currentClickType == MouseClickType.Middle; if (currentClickType != MouseClickType.None && oldClickType == MouseClickType.None) { currentMouseClickStartedInWindow = mouseInWindow; } if (currentClickType == MouseClickType.None) { // If nothing is pressed, just dont bother lerping mousePos = new Vector2(mouse.X, mouse.Y); } bool isSpeedupKeyPressed = keyboard.IsKeyDown(Keys.LeftControl) || keyboard.IsKeyDown(Keys.RightControl); bool isSlowdownKeyPressed = keyboard.IsKeyDown(Keys.LeftShift) || keyboard.IsKeyDown(Keys.RightShift); bool isResetKeyPressed = keyboard.IsKeyDown(Keys.R); bool isMoveLightKeyPressed = keyboard.IsKeyDown(Keys.Space); bool isOrbitCamToggleKeyPressed = false; // keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F); bool isPointCamAtObjectKeyPressed = false; // keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.T); if (!currentMouseClickStartedInWindow) { oldMouse = mousePos; if (IsOrbitCam) { //DEBUG("Dist:" + ORBIT_CAM_DISTANCE); //DEBUG("AngX:" + CameraTransform.Rotation.X / MathHelper.Pi + " PI"); //DEBUG("AngY:" + CameraTransform.Rotation.Y / MathHelper.Pi + " PI"); //DEBUG("AngZ:" + CameraTransform.Rotation.Z / MathHelper.Pi + " PI"); CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP, MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP); OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.Forward, CameraTransform.RotationMatrixXYZ * Matrix.CreateRotationY(MathHelper.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * (OrbitCamDistance * OrbitCamDistance))); } else { CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); } //LightRotation.X = MathHelper.Clamp(LightRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); oldWheel = currentWheel; //prev_isToggleAllSubmeshKeyPressed = isToggleAllSubmeshKeyPressed; //prev_isToggleAllDummyKeyPressed = isToggleAllDummyKeyPressed; //prev_isToggleAllBonesKeyPressed = isToggleAllBonesKeyPressed; oldClickType = currentClickType; oldMouseClickL = currentMouseClickL; oldMouseClickR = currentMouseClickR; oldMouseClickM = currentMouseClickM; oldOrbitCamToggleKeyPressed = isOrbitCamToggleKeyPressed; return; } if (currentMouseClickM && !oldMouseClickM && IsOrbitCam) { OrbitCamReset(); } if (currentClickType == MouseClickType.None && gamepad.IsConnected) { if (gamepad.IsButtonDown(Buttons.LeftShoulder)) { isSlowdownKeyPressed = true; } if (gamepad.IsButtonDown(Buttons.RightShoulder)) { isSpeedupKeyPressed = true; } if (gamepad.IsButtonDown(Buttons.RightStick)) { isResetKeyPressed = true; } if (gamepad.IsButtonDown(Buttons.LeftStick)) { isMoveLightKeyPressed = true; } //if (gamepad.IsButtonDown(Buttons.DPadDown)) // isOrbitCamToggleKeyPressed = true; //if (gamepad.IsButtonDown(Buttons.RightStick)) // isPointCamAtObjectKeyPressed = true; } if (isResetKeyPressed && !oldResetKeyPressed) { ResetCameraLocation(); } oldResetKeyPressed = isResetKeyPressed; if (isOrbitCamToggleKeyPressed && !oldOrbitCamToggleKeyPressed) { if (!IsOrbitCam) { CameraOrigin.Position.Y = CameraPositionDefault.Position.Y; OrbitCamDistance = (CameraOrigin.Position - (CameraTransform.Position)).Length(); } IsOrbitCam = !IsOrbitCam; } if (isPointCamAtObjectKeyPressed) { PointCameraToLocation(CameraPositionDefault.Position); } float moveMult = elapsed * CameraMoveSpeed; if (isSpeedupKeyPressed) { moveMult *= 10f; } if (isSlowdownKeyPressed) { moveMult /= 10f; } var cameraDist = CameraOrigin.Position - CameraTransform.Position; if (currentClickType == MouseClickType.None && gamepad.IsConnected) { var lt = GetGamepadTriggerDeadzone(gamepad.Triggers.Left, 0.1f); var rt = GetGamepadTriggerDeadzone(gamepad.Triggers.Right, 0.1f); if (IsOrbitCam && !isMoveLightKeyPressed) { float camH = gamepad.ThumbSticks.Left.X * (float)1.5f * CameraTurnSpeedGamepad * elapsed; float camV = gamepad.ThumbSticks.Left.Y * (float)1.5f * CameraTurnSpeedGamepad * elapsed; //DEBUG($"{(CameraTransform.Rotation.X / MathHelper.PiOver2)}"); if (CameraTransform.EulerRotation.X >= MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { //DEBUG("UPPER CAM LIMIT"); camV = Math.Min(camV, 0); } if (CameraTransform.EulerRotation.X <= -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { //DEBUG("LOWER CAM LIMIT"); camV = Math.Max(camV, 0); } RotateCameraOrbit(camH, camV, MathHelper.PiOver2); var zoom = gamepad.Triggers.Right - gamepad.Triggers.Left; if (Math.Abs(cameraDist.Length()) <= SHITTY_CAM_ZOOM_MIN_DIST) { zoom = Math.Min(zoom, 0); } OrbitCamDistance -= zoom * moveMult; //PointCameraToModel(); MoveCamera_OrbitCenterPoint(gamepad.ThumbSticks.Right.X, gamepad.ThumbSticks.Right.Y, 0, moveMult); } else { float camH = gamepad.ThumbSticks.Right.X * (float)1.5f * CameraTurnSpeedGamepad * elapsed; float camV = gamepad.ThumbSticks.Right.Y * (float)1.5f * CameraTurnSpeedGamepad * elapsed; if (isMoveLightKeyPressed) { LightRotationH += camH; LightRotationV -= camV; } else { MoveCamera(gamepad.ThumbSticks.Left.X, gamepad.Triggers.Right - gamepad.Triggers.Left, gamepad.ThumbSticks.Left.Y, moveMult); CameraTransform.EulerRotation.Y -= camH; CameraTransform.EulerRotation.X += camV; } } } if (IsOrbitCam) { if (currentMouseClickL) { float x = 0; float z = 0; float y = 0; if (keyboard.IsKeyDown(Keys.W) && Math.Abs(cameraDist.Length()) > 0.1f) { z += 1; } if (keyboard.IsKeyDown(Keys.S)) { z -= 1; } if (keyboard.IsKeyDown(Keys.E)) { y += 1; } if (keyboard.IsKeyDown(Keys.Q)) { y -= 1; } if (keyboard.IsKeyDown(Keys.A)) { x -= 1; } if (keyboard.IsKeyDown(Keys.D)) { x += 1; } if (Math.Abs(cameraDist.Length()) <= SHITTY_CAM_ZOOM_MIN_DIST) { z = Math.Min(z, 0); } //OrbitCamDistance -= z * moveMult; //MoveCamera_OrbitCenterPoint(x, y, 0, moveMult * 4); } else if (currentMouseClickR) { MoveCamera_OrbitCenterPoint_MouseDelta(mousePos, oldMouse, elapsed); //Vector2 mouseDelta = mousePos - oldMouse; //MoveCamera_OrbitCenterPoint(-mouseDelta.X, mouseDelta.Y, 0, moveMult); } if (GFX.LastViewport.Bounds.Contains(mouse.Position)) { OrbitCamDistance -= ((currentWheel - oldWheel) / 150f) * 0.25f; } } else { float x = 0; float y = 0; float z = 0; if (keyboard.IsKeyDown(Keys.D)) { x += 1; } if (keyboard.IsKeyDown(Keys.A)) { x -= 1; } if (keyboard.IsKeyDown(Keys.E)) { y += 1; } if (keyboard.IsKeyDown(Keys.Q)) { y -= 1; } if (keyboard.IsKeyDown(Keys.W)) { z += 1; } if (keyboard.IsKeyDown(Keys.S)) { z -= 1; } MoveCamera(x, y, z, moveMult); } //if (isToggleAllSubmeshKeyPressed && !prev_isToggleAllSubmeshKeyPressed) //{ // game.ModelListWindow.TOGGLE_ALL_SUBMESH(); //} //if (isToggleAllDummyKeyPressed && !prev_isToggleAllDummyKeyPressed) //{ // game.ModelListWindow.TOGGLE_ALL_DUMMY(); //} //if (isToggleAllBonesKeyPressed && !prev_isToggleAllBonesKeyPressed) //{ // game.ModelListWindow.TOGGLE_ALL_BONES(); //} if (currentMouseClickL) { if (!oldMouseClickL) { //game.IsMouseVisible = false; oldMouse = mousePos; //Mouse.SetPosition(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); //mousePos = new Vector2(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); //oldMouseClick = true; //return; } else { //game.IsMouseVisible = false; Vector2 mouseDelta = mousePos - oldMouse; if (mouseDelta.LengthSquared() == 0) { // Prevents a meme oldWheel = currentWheel; return; } //Mouse.SetPosition(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); float camH = mouseDelta.X * 1 * CameraTurnSpeedMouse * elapsed * 0.15f; float camV = mouseDelta.Y * -1 * CameraTurnSpeedMouse * elapsed * 0.15f; if (IsOrbitCam && !isMoveLightKeyPressed) { if (CameraTransform.EulerRotation.X >= MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { camV = Math.Min(camV, 0); } if (CameraTransform.EulerRotation.X <= -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { camV = Math.Max(camV, 0); } RotateCameraOrbit(camH, camV, MathHelper.PiOver2); //PointCameraToModel(); } else if (isMoveLightKeyPressed) { LightRotationH += camH; LightRotationV -= camV; } else { CameraTransform.EulerRotation.Y -= camH; CameraTransform.EulerRotation.X += camV; } } //CameraTransform.Rotation.Z -= (float)Math.Cos(MathHelper.PiOver2 - CameraTransform.Rotation.Y) * camV; //RotateCamera(mouseDelta.Y * -0.01f * (float)moveMult, 0, 0, moveMult); //RotateCamera(0, mouseDelta.X * 0.01f * (float)moveMult, 0, moveMult); } else { //var requestDirChange = RequestDirectionChange; //if (requestDirChange != 0) //{ // CameraTransform.EulerRotation.Y += requestDirChange; // RequestDirectionChange -= requestDirChange; //} if (IsOrbitCam) { RotateCameraOrbit(0, 0, MathHelper.PiOver2); } if (oldMouseClickL) { //Mouse.SetPosition((int)oldMouse.X, (int)oldMouse.Y); } //game.IsMouseVisible = true; } if (IsOrbitCam) { //DEBUG("Dist:" + ORBIT_CAM_DISTANCE); //DEBUG("AngX:" + CameraTransform.Rotation.X / MathHelper.Pi + " PI"); //DEBUG("AngY:" + CameraTransform.Rotation.Y / MathHelper.Pi + " PI"); //DEBUG("AngZ:" + CameraTransform.Rotation.Z / MathHelper.Pi + " PI"); CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP, MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP); OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.Forward, CameraTransform.RotationMatrixXYZ * Matrix.CreateRotationY(MathHelper.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * (OrbitCamDistance * OrbitCamDistance))); } else { CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); } LightRotationV = MathHelper.Clamp(LightRotationV, -MathHelper.PiOver2, MathHelper.PiOver2); oldWheel = currentWheel; //prev_isToggleAllSubmeshKeyPressed = isToggleAllSubmeshKeyPressed; //prev_isToggleAllDummyKeyPressed = isToggleAllDummyKeyPressed; //prev_isToggleAllBonesKeyPressed = isToggleAllBonesKeyPressed; oldClickType = currentClickType; oldMouseClickL = currentMouseClickL; oldMouseClickR = currentMouseClickR; oldMouseClickM = currentMouseClickM; oldOrbitCamToggleKeyPressed = isOrbitCamToggleKeyPressed; oldMouse = mousePos; }
protected virtual void ProcessMouseActivity(int currentX, int currentY, MouseButton buttonClicked, MouseButtonState buttonState, MouseClickType clickType, int wheelDelta) { lock (this) { string activeProcessName = ActiveApplicationMonitor.GetActiveApplicationName(); DateTime now = DateTime.Now; if (buttonClicked != MouseButton.None) { #region Mouse was clicked LastClickX = CurrentMouseX; LastClickY = CurrentMouseY; _largestDistanceMovedSinceLastClick = 0; // Fire click event FireClickEvent( new MouseClickEvent( activeProcessName, currentX, currentY, buttonClicked, buttonState, clickType, now ) ); #endregion } if (CurrentMouseX != currentX || CurrentMouseY != currentY) { #region Mouse was moved _lastMouseMoveOn = now; PreviousMouseX = CurrentMouseX; PreviousMouseY = CurrentMouseY; CurrentMouseX = currentX; CurrentMouseY = currentY; // Keep track of distances moved by mouse int distanceFromStart = (int) Math.Round(Math.Sqrt(Math.Pow(CurrentMouseX - MotionStartX, 2) + Math.Pow(CurrentMouseY - MotionStartY, 2)), 0); if (distanceFromStart > _largestDistanceMovedSinceMotionStart) { _largestDistanceMovedSinceMotionStart = distanceFromStart; } int distanceFromClick = (int)Math.Round(Math.Sqrt(Math.Pow(CurrentMouseX - LastClickX, 2) + Math.Pow(CurrentMouseY - LastClickY, 2)), 0); if (distanceFromClick > _largestDistanceMovedSinceLastClick) { _largestDistanceMovedSinceLastClick = distanceFromClick; } int distanceFromLastEvent = (int) Math.Round(Math.Sqrt(Math.Pow(CurrentMouseX - PreviousMouseX, 2) + Math.Pow(CurrentMouseY - PreviousMouseY, 2)), 0); if (!_inMotion) { // Mouse was previously stationary, now begins motion _inMotion = true; _largestDistanceMovedSinceMotionStart = 0; MotionStartX = CurrentMouseX; MotionStartY = CurrentMouseY; PreviousMouseX = CurrentMouseX; PreviousMouseY = CurrentMouseY; // Raise move start moving event FireMotionStartEvent( new MouseMoveEvent( activeProcessName, MouseMotionType.Started, CurrentMouseX, CurrentMouseY, distanceFromStart, distanceFromLastEvent, distanceFromClick, now ) ); } if (_inMotion) { #region Detect mouse stopped if (_detectingMouseStoppedSemaphore.Wait(0)) { // We detect a stop in motion when the mouse hasn't moved within MovingStoppedInterval Tools.Lambda.ActionAsAsyncronous( () => { try { while (DateTime.Now.Subtract(_lastMouseMoveOn) < MovingStoppedInterval) { Thread.Sleep(MovingStoppedInterval); } _inMotion = false; // The mouse hasn't moved in MovingStoppedInterval, so fire a mouse stopped event FireMotionStopEvent( new MouseMoveEvent( ActiveApplicationMonitor.GetActiveApplicationName(), MouseMotionType.Stopped, CurrentMouseX, CurrentMouseY, _largestDistanceMovedSinceMotionStart, 0, _largestDistanceMovedSinceLastClick, DateTime.UtcNow ) ); } finally { _detectingMouseStoppedSemaphore.Release(); } }).Invoke(); #endregion } } // Raise mouse motion event FireMotionEvent( new MouseMoveEvent( activeProcessName, MouseMotionType.Move, CurrentMouseX, CurrentMouseY, distanceFromStart, distanceFromLastEvent, distanceFromClick, now ) ); #endregion } if (wheelDelta != 0) { #region Mouse was scrolled FireScrollEvent( new MouseWheelEvent( activeProcessName, currentX, currentY, now, wheelDelta ) ); #endregion } // Raise generic mouse activity event FireActivityEvent( new MouseEvent( activeProcessName, currentX, currentY, now ) ); } }
private Func <bool> createMouseFunc(int moveX, int moveY, bool moveAbsolute, int scrollHor, int scrollVert, MouseClickType mouseClickType, int xID) { Func <bool> result = () => { if (moveAbsolute) { Cursor.Position = new Point(moveX, moveY); } else if (moveX != 0 || moveY != 0) { Point curPos = Cursor.Position; Cursor.Position = new Point(curPos.X + moveX, curPos.Y + moveY); } if (scrollHor != 0) { inputSim.Mouse.HorizontalScroll(scrollHor); } if (scrollVert != 0) { inputSim.Mouse.VerticalScroll(scrollVert); } switch (mouseClickType) { case MouseClickType.None: break; case MouseClickType.LeftDown: inputSim.Mouse.LeftButtonDown(); break; case MouseClickType.LeftUp: inputSim.Mouse.LeftButtonUp(); break; case MouseClickType.LeftClick: inputSim.Mouse.LeftButtonClick(); break; case MouseClickType.LeftDoubleClick: inputSim.Mouse.LeftButtonDoubleClick(); break; case MouseClickType.RightDown: inputSim.Mouse.RightButtonDown(); break; case MouseClickType.RightUp: inputSim.Mouse.RightButtonUp(); break; case MouseClickType.RightClick: inputSim.Mouse.RightButtonClick(); break; case MouseClickType.RightDoubleClick: inputSim.Mouse.RightButtonDoubleClick(); break; case MouseClickType.XDown: inputSim.Mouse.XButtonDown(xID); break; case MouseClickType.XUp: inputSim.Mouse.XButtonUp(xID); break; case MouseClickType.XClick: inputSim.Mouse.XButtonClick(xID); break; case MouseClickType.XDoubleClick: inputSim.Mouse.XButtonDoubleClick(xID); break; } return(true); }; return(result); }
public void SendMouseClick(MouseClickType type) { if (state != State.ACTIVE) return; try { byte[] msg = null; switch (type) { case MouseClickType.LEFT_DOWN: msg = TipoComandoBytes.CLICK_LEFT_DOWN; break; case MouseClickType.LEFT_UP: msg = TipoComandoBytes.CLICK_LEFT_UP; break; case MouseClickType.MIDDLE_DOWN: msg = TipoComandoBytes.CLICK_MIDDLE_DOWN; break; case MouseClickType.MIDDLE_UP: msg = TipoComandoBytes.CLICK_MIDDLE_UP; break; case MouseClickType.RIGHT_DOWN: msg = TipoComandoBytes.CLICK_RIGHT_DOWN; break; case MouseClickType.RIGHT_UP: msg = TipoComandoBytes.CLICK_RIGHT_UP; break; } WriteMessageMouse(msg); } catch (NetworkException) { Trace.TraceError("NetworkException in SendMouseClick()."); state = State.CLOSED_ERROR_NETWORK; controlConnectionWorker.CancelAsync(); } catch (Exception se) { Trace.TraceError("Exception in SendMouseClick(). Stack trace:\n{0}\n", se.StackTrace); if (se is IOException || se is SocketException) { state = State.CLOSED_ERROR_SERVER; controlConnectionWorker.CancelAsync(); } else { state = State.CLOSED_ERROR_SERVER; controlConnectionWorker.CancelAsync(); } } }
public WorldObjectSelectedEventArgs(IWorldObjectModel objectModel, MouseClickType clickType) { this.objectModel = objectModel; this.clickType = clickType; }
public bool UpdateInput(Sdl2Window window, float dt) { if (DisableAllInput) { //oldWheel = Mouse.GetState(game.Window).ScrollWheelValue; return false; } float clampedLerpF = Utils.Clamp(30 * dt, 0, 1); mousePos = new Vector2(Utils.Lerp(oldMouse.X, InputTracker.MousePosition.X, clampedLerpF), Utils.Lerp(oldMouse.Y, InputTracker.MousePosition.Y, clampedLerpF)); //KeyboardState keyboard = DBG.EnableKeyboardInput ? Keyboard.GetState() : DBG.DisabledKeyboardState; //int currentWheel = mouse.ScrollWheelValue; //bool mouseInWindow = MapStudio.Active && mousePos.X >= game.ClientBounds.Left && mousePos.X < game.ClientBounds.Right && mousePos.Y > game.ClientBounds.Top && mousePos.Y < game.ClientBounds.Bottom; currentClickType = MouseClickType.None; if (InputTracker.GetMouseButton(Veldrid.MouseButton.Left)) currentClickType = MouseClickType.Left; else if (InputTracker.GetMouseButton(Veldrid.MouseButton.Right)) currentClickType = MouseClickType.Right; else if (InputTracker.GetMouseButton(Veldrid.MouseButton.Middle)) currentClickType = MouseClickType.Middle; else if (InputTracker.GetMouseButton(Veldrid.MouseButton.Button1)) currentClickType = MouseClickType.Extra1; else if (InputTracker.GetMouseButton(Veldrid.MouseButton.Button2)) currentClickType = MouseClickType.Extra2; else currentClickType = MouseClickType.None; currentMouseClickL = currentClickType == MouseClickType.Left; currentMouseClickR = currentClickType == MouseClickType.Right; currentMouseClickM = currentClickType == MouseClickType.Middle; if (currentClickType != MouseClickType.None && oldClickType == MouseClickType.None) currentMouseClickStartedInWindow = true; if (currentClickType == MouseClickType.None) { // If nothing is pressed, just dont bother lerping //mousePos = new Vector2(mouse.X, mouse.Y); if (MousePressed) { mousePos = InputTracker.MousePosition; Sdl2Native.SDL_WarpMouseInWindow(window.SdlWindowHandle, (int)MousePressedPos.X, (int)MousePressedPos.Y); Sdl2Native.SDL_SetWindowGrab(window.SdlWindowHandle, false); Sdl2Native.SDL_ShowCursor(1); MousePressed = false; } return false; } bool isSpeedupKeyPressed = InputTracker.GetKey(Veldrid.Key.LShift) || InputTracker.GetKey(Veldrid.Key.RShift); bool isSlowdownKeyPressed = InputTracker.GetKey(Veldrid.Key.LControl) || InputTracker.GetKey(Veldrid.Key.RControl); bool isResetKeyPressed = InputTracker.GetKey(Veldrid.Key.R); bool isMoveLightKeyPressed = InputTracker.GetKey(Veldrid.Key.Space); bool isOrbitCamToggleKeyPressed = false;// keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F); bool isPointCamAtObjectKeyPressed = false;// keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.T); if (!currentMouseClickStartedInWindow) { oldMouse = mousePos; if (IsOrbitCam) { OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.UnitX, CameraTransform.RotationMatrixXYZ * Matrix4x4.CreateRotationY(Utils.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * (OrbitCamDistance * OrbitCamDistance))); } else { var eu = CameraTransform.EulerRotation; eu.X = Utils.Clamp(CameraTransform.EulerRotation.X, -Utils.PiOver2, Utils.PiOver2); CameraTransform.EulerRotation = eu; } LightRotation.X = Utils.Clamp(LightRotation.X, -Utils.PiOver2, Utils.PiOver2); oldClickType = currentClickType; oldMouseClickL = currentMouseClickL; oldMouseClickR = currentMouseClickR; oldMouseClickM = currentMouseClickM; oldOrbitCamToggleKeyPressed = isOrbitCamToggleKeyPressed; return true; } if (currentMouseClickM && !oldMouseClickM && IsOrbitCam) { OrbitCamReset(); } if (isResetKeyPressed && !oldResetKeyPressed) { ResetCameraLocation(); } oldResetKeyPressed = isResetKeyPressed; if (isOrbitCamToggleKeyPressed && !oldOrbitCamToggleKeyPressed) { if (!IsOrbitCam) { CameraOrigin.Position.Y = CameraPositionDefault.Position.Y; OrbitCamDistance = (CameraOrigin.Position - (CameraTransform.Position)).Length(); } IsOrbitCam = !IsOrbitCam; } if (isPointCamAtObjectKeyPressed) { PointCameraToLocation(CameraPositionDefault.Position); } float moveMult = dt * CameraMoveSpeed; if (isSpeedupKeyPressed) { moveMult = dt * CameraMoveSpeedFast; } if (isSlowdownKeyPressed) { moveMult = dt * CameraMoveSpeedSlow; } var cameraDist = CameraOrigin.Position - CameraTransform.Position; if (IsOrbitCam) { if (currentMouseClickL) { float x = 0; float z = 0; float y = 0; if (InputTracker.GetKeyDown(Veldrid.Key.W) && Math.Abs(cameraDist.Length()) > 0.1f) z += 1; if (InputTracker.GetKeyDown(Veldrid.Key.S)) z -= 1; if (InputTracker.GetKeyDown(Veldrid.Key.E)) y += 1; if (InputTracker.GetKeyDown(Veldrid.Key.Q)) y -= 1; if (InputTracker.GetKeyDown(Veldrid.Key.A)) x -= 1; if (InputTracker.GetKeyDown(Veldrid.Key.D)) x += 1; if (Math.Abs(cameraDist.Length()) <= SHITTY_CAM_ZOOM_MIN_DIST) { z = Math.Min(z, 0); } } else if (currentMouseClickR) { MoveCamera_OrbitCenterPoint_MouseDelta(mousePos, oldMouse); //Vector2 mouseDelta = mousePos - oldMouse; //MoveCamera_OrbitCenterPoint(-mouseDelta.X, mouseDelta.Y, 0, moveMult); } //if (GFX.LastViewport.Bounds.Contains(mouse.Position)) // OrbitCamDistance -= ((currentWheel - oldWheel) / 150f) * 0.25f; } else { float x = 0; float y = 0; float z = 0; if (InputTracker.GetKey(Veldrid.Key.D)) x += 1; if (InputTracker.GetKey(Veldrid.Key.A)) x -= 1; if (InputTracker.GetKey(Veldrid.Key.E)) y += 1; if (InputTracker.GetKey(Veldrid.Key.Q)) y -= 1; if (InputTracker.GetKey(Veldrid.Key.W)) z += 1; if (InputTracker.GetKey(Veldrid.Key.S)) z -= 1; MoveCamera(x, y, z, moveMult); } if (currentMouseClickR) { if (!MousePressed) { var x = InputTracker.MousePosition.X; var y = InputTracker.MousePosition.Y; if (x >= BoundingRect.Left && x < BoundingRect.Right && y >= BoundingRect.Top && y < BoundingRect.Bottom) { MousePressed = true; MousePressedPos = InputTracker.MousePosition; Sdl2Native.SDL_ShowCursor(0); Sdl2Native.SDL_SetWindowGrab(window.SdlWindowHandle, true); } } else { Vector2 mouseDelta = MousePressedPos - InputTracker.MousePosition; Sdl2Native.SDL_WarpMouseInWindow(window.SdlWindowHandle, (int)MousePressedPos.X, (int)MousePressedPos.Y); if (mouseDelta.LengthSquared() == 0) { // Prevents a meme //oldWheel = currentWheel; return true; } //Mouse.SetPosition(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); float camH = mouseDelta.X * 1 * CameraTurnSpeedMouse * 0.0160f; float camV = mouseDelta.Y * -1 * CameraTurnSpeedMouse * 0.0160f; if (IsOrbitCam && !isMoveLightKeyPressed) { if (CameraTransform.EulerRotation.X >= Utils.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { camV = Math.Min(camV, 0); } if (CameraTransform.EulerRotation.X <= -Utils.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { camV = Math.Max(camV, 0); } RotateCameraOrbit(camH, camV, Utils.PiOver2); //PointCameraToModel(); } else if (isMoveLightKeyPressed) { LightRotation.Y += camH; LightRotation.X -= camV; } else { var eu = CameraTransform.EulerRotation; eu.Y -= camH; eu.X += camV; CameraTransform.EulerRotation = eu; } } //CameraTransform.Rotation.Z -= (float)Math.Cos(MathHelper.PiOver2 - CameraTransform.Rotation.Y) * camV; //RotateCamera(mouseDelta.Y * -0.01f * (float)moveMult, 0, 0, moveMult); //RotateCamera(0, mouseDelta.X * 0.01f * (float)moveMult, 0, moveMult); } else { if (MousePressed) { Sdl2Native.SDL_WarpMouseInWindow(window.SdlWindowHandle, (int)MousePressedPos.X, (int)MousePressedPos.Y); Sdl2Native.SDL_SetWindowGrab(window.SdlWindowHandle, false); Sdl2Native.SDL_ShowCursor(1); MousePressed = false; } if (IsOrbitCam) { RotateCameraOrbit(0, 0, Utils.PiOver2); } if (oldMouseClickL) { //Mouse.SetPosition((int)oldMouse.X, (int)oldMouse.Y); } //game.IsMouseVisible = true; } if (IsOrbitCam) { OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.UnitX, CameraTransform.RotationMatrixXYZ * Matrix4x4.CreateRotationY(Utils.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * (OrbitCamDistance * OrbitCamDistance))); } else { var eu = CameraTransform.EulerRotation; eu.X = Utils.Clamp(CameraTransform.EulerRotation.X, -Utils.PiOver2, Utils.PiOver2); CameraTransform.EulerRotation = eu; } LightRotation.X = Utils.Clamp(LightRotation.X, -Utils.PiOver2, Utils.PiOver2); oldClickType = currentClickType; oldMouseClickL = currentMouseClickL; oldMouseClickR = currentMouseClickR; oldMouseClickM = currentMouseClickM; oldOrbitCamToggleKeyPressed = isOrbitCamToggleKeyPressed; oldMouse = mousePos; return true; }
private void AddInputButton_Click(object sender, EventArgs e) { try { List <TimelineItem> tempItems = new List <TimelineItem>(); // it's a list because sometimes we need to add two events tempItems.Add(new TimelineItem()); // there will always be one event added InputType tabType = (InputType)Enum.Parse(typeof(InputType), InputTypeTabs.SelectedTab.Text, true); switch (tabType) { case InputType.KeyCode: if (!HardwareKeyCodeTabCheck.Checked) { VirtualKeyCode virtualKeyCode = (VirtualKeyCode)KeyCodeTabCombo.SelectedItem; if (SplitKeyCodeTabCheck.Checked) { tempItems[0].name = tabType.ToString() + " - Pressed Down " + virtualKeyCode.ToString(); tempItems[0].func = createKeyCodeFunc(KeyPressType.Down, virtualKeyCode); tempItems.Add(new TimelineItem()); tempItems[1].name = tabType.ToString() + " - Pressed Up " + virtualKeyCode.ToString(); tempItems[1].func = createKeyCodeFunc(KeyPressType.Up, virtualKeyCode); } else // We just do a regular keypress { tempItems[0].name = tabType.ToString() + " - Pressed Down & Up " + virtualKeyCode.ToString(); tempItems[0].func = createKeyCodeFunc(KeyPressType.Press, virtualKeyCode); } } else // use hardware key input instead { Keyboard.ScanCodeShort scanCode = (Keyboard.ScanCodeShort)HardwareKeyCodeTabCombo.SelectedItem; tempItems[0].name = tabType.ToString() + " - Hardware input " + scanCode.ToString(); tempItems[0].func = createHardwareKeyCodeFunc(scanCode); } break; case InputType.Mouse: int moveX = (int)MoveXMouseTabInput.Value; int moveY = (int)MoveYMouseTabInput.Value; bool moveAbsolute = AbsoluteMouseTabCheck.Checked; int scrollHor = (int)ScrollHorMouseTabInput.Value; int scrollVert = (int)ScrollVertMouseTabInput.Value; MouseClickType mouseClickType = (MouseClickType)MouseClickMouseTabCombo.SelectedItem; int xID = (int)XIDMouseTabInput.Value; tempItems[0].name = tabType.ToString() + " - "; if (moveX != 0 || moveY != 0 || moveAbsolute) { tempItems[0].name += "Move " + (moveAbsolute? "to " : "by ") + moveX + "," + moveY + " "; } if (scrollHor != 0 || scrollVert != 0) { tempItems[0].name += "Scroll by " + scrollHor + "," + scrollVert + " "; } if (mouseClickType != MouseClickType.None) { tempItems[0].name += mouseClickType.ToString() + " "; if (mouseClickType.ToString().Contains("X")) { tempItems[0].name += "button ID " + xID + " "; } } if (moveX == 0 && moveY == 0 && !moveAbsolute && scrollHor == 0 && scrollVert == 0 && mouseClickType == MouseClickType.None) { throw new Exception("No mouse input configuration was made"); } tempItems[0].func = createMouseFunc(moveX, moveY, moveAbsolute, scrollHor, scrollVert, mouseClickType, xID); break; case InputType.String: string message = StringTabInput.Text; if (message.Length > 1000) { throw new Exception("String message too long"); } tempItems[0].name = tabType.ToString() + " - \"" + message + "\""; tempItems[0].func = createStringFunc(message); break; case InputType.Delay: int delay = (int)DelayTabInput.Value; tempItems[0].name = tabType.ToString() + " - " + delay + "ms"; tempItems[0].func = createDelayFunc(delay); break; default: throw new Exception("Somehow, no input type tab was selected."); } TimelineList.Items.AddRange(tempItems.ToArray()); } catch (Exception err) { Console.WriteLine("Error occurred when trying to add new input to timeline: {0}", err.Message); } }
/// <summary> /// Default ClickDown /// </summary> /// <param name="type"></param> public DiscreteClick(MouseClickType type) : this(type, true) { }
public MouseClickEventArgs(MouseClickType clickType) { this.clickType = clickType; }
public void UpdateInput(Main game, GameTime gameTime) { if (DisableAllInput) { return; } //if (GFX.TestLightSpin) //{ // LightRotation.Y += MathHelper.PiOver4 * (float)gameTime.ElapsedGameTime.TotalSeconds; // LightRotation.X += MathHelper.PiOver4 * (float)gameTime.ElapsedGameTime.TotalSeconds; //} var gamepad = DBG.EnableGamePadInput ? GamePad.GetState(PlayerIndex.One) : DBG.DisabledGamePadState; MouseState mouse = DBG.EnableMouseInput ? Mouse.GetState(game.Window) : DBG.DisabledMouseState; mousePos = new Vector2((float)mouse.X, (float)mouse.Y); KeyboardState keyboard = DBG.EnableKeyboardInput ? Keyboard.GetState() : DBG.DisabledKeyboardState; int currentWheel = mouse.ScrollWheelValue; bool mouseInWindow = Main.Active && mousePos.X >= game.ClientBounds.Left && mousePos.X <game.ClientBounds.Right && mousePos.Y> game.ClientBounds.Top && mousePos.Y < game.ClientBounds.Bottom; currentClickType = MouseClickType.None; if (mouse.LeftButton == ButtonState.Pressed) { currentClickType = MouseClickType.Left; } else if (mouse.RightButton == ButtonState.Pressed) { currentClickType = MouseClickType.Right; } else if (mouse.MiddleButton == ButtonState.Pressed) { currentClickType = MouseClickType.Middle; } else if (mouse.XButton1 == ButtonState.Pressed) { currentClickType = MouseClickType.Extra1; } else if (mouse.XButton2 == ButtonState.Pressed) { currentClickType = MouseClickType.Extra2; } else { currentClickType = MouseClickType.None; } currentMouseClickL = currentClickType == MouseClickType.Left; currentMouseClickR = currentClickType == MouseClickType.Right; currentMouseClickM = currentClickType == MouseClickType.Middle; if (currentClickType != MouseClickType.None && oldClickType == MouseClickType.None) { currentMouseClickStartedInWindow = mouseInWindow; } bool isSpeedupKeyPressed = keyboard.IsKeyDown(Keys.LeftControl) || keyboard.IsKeyDown(Keys.RightControl); bool isSlowdownKeyPressed = keyboard.IsKeyDown(Keys.LeftShift) || keyboard.IsKeyDown(Keys.RightShift); bool isResetKeyPressed = keyboard.IsKeyDown(Keys.R); bool isMoveLightKeyPressed = keyboard.IsKeyDown(Keys.Space); bool isOrbitCamToggleKeyPressed = false; // keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F); bool isPointCamAtObjectKeyPressed = false; // keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.T); if (!currentMouseClickStartedInWindow) { oldMouse = mousePos; if (IsOrbitCam) { //DEBUG("Dist:" + ORBIT_CAM_DISTANCE); //DEBUG("AngX:" + CameraTransform.Rotation.X / MathHelper.Pi + " PI"); //DEBUG("AngY:" + CameraTransform.Rotation.Y / MathHelper.Pi + " PI"); //DEBUG("AngZ:" + CameraTransform.Rotation.Z / MathHelper.Pi + " PI"); CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP, MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP); OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.Forward, CameraTransform.RotationMatrixXYZ * Matrix.CreateRotationY(MathHelper.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * OrbitCamDistance)); } else { CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); } LightRotation.X = MathHelper.Clamp(LightRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); oldWheel = currentWheel; //prev_isToggleAllSubmeshKeyPressed = isToggleAllSubmeshKeyPressed; //prev_isToggleAllDummyKeyPressed = isToggleAllDummyKeyPressed; //prev_isToggleAllBonesKeyPressed = isToggleAllBonesKeyPressed; oldClickType = currentClickType; oldMouseClickL = currentMouseClickL; oldMouseClickR = currentMouseClickR; oldMouseClickM = currentMouseClickM; oldOrbitCamToggleKeyPressed = isOrbitCamToggleKeyPressed; return; } if (currentMouseClickM && !oldMouseClickM && IsOrbitCam) { OrbitCamReset(); } if (currentClickType == MouseClickType.None && gamepad.IsConnected) { if (gamepad.IsButtonDown(Buttons.LeftShoulder)) { isSlowdownKeyPressed = true; } if (gamepad.IsButtonDown(Buttons.RightShoulder)) { isSpeedupKeyPressed = true; } if (gamepad.IsButtonDown(Buttons.RightStick)) { isResetKeyPressed = true; } if (gamepad.IsButtonDown(Buttons.LeftStick)) { isMoveLightKeyPressed = true; } //if (gamepad.IsButtonDown(Buttons.DPadDown)) // isOrbitCamToggleKeyPressed = true; //if (gamepad.IsButtonDown(Buttons.RightStick)) // isPointCamAtObjectKeyPressed = true; } if (isResetKeyPressed && !oldResetKeyPressed) { ResetCameraLocation(); } oldResetKeyPressed = isResetKeyPressed; if (isOrbitCamToggleKeyPressed && !oldOrbitCamToggleKeyPressed) { if (!IsOrbitCam) { CameraOrigin.Position.Y = CameraPositionDefault.Position.Y; OrbitCamDistance = (CameraOrigin.Position - (CameraTransform.Position)).Length(); } IsOrbitCam = !IsOrbitCam; } if (isPointCamAtObjectKeyPressed) { PointCameraToLocation(CameraPositionDefault.Position); } float moveMult = (float)gameTime.ElapsedGameTime.TotalSeconds * CameraMoveSpeed; if (isSpeedupKeyPressed) { moveMult *= 10f; } if (isSlowdownKeyPressed) { moveMult /= 10f; } var cameraDist = CameraOrigin.Position - CameraTransform.Position; if (currentClickType == MouseClickType.None && gamepad.IsConnected) { var lt = GetGamepadTriggerDeadzone(gamepad.Triggers.Left, 0.1f); var rt = GetGamepadTriggerDeadzone(gamepad.Triggers.Right, 0.1f); if (IsOrbitCam && !isMoveLightKeyPressed) { float camH = gamepad.ThumbSticks.Left.X * (float)1.5f * CameraTurnSpeedGamepad * (float)gameTime.ElapsedGameTime.TotalSeconds; float camV = gamepad.ThumbSticks.Left.Y * (float)1.5f * CameraTurnSpeedGamepad * (float)gameTime.ElapsedGameTime.TotalSeconds; //DEBUG($"{(CameraTransform.Rotation.X / MathHelper.PiOver2)}"); if (CameraTransform.EulerRotation.X >= MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { //DEBUG("UPPER CAM LIMIT"); camV = Math.Min(camV, 0); } if (CameraTransform.EulerRotation.X <= -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { //DEBUG("LOWER CAM LIMIT"); camV = Math.Max(camV, 0); } RotateCameraOrbit(camH, camV, MathHelper.PiOver2); var zoom = gamepad.Triggers.Right - gamepad.Triggers.Left; if (Math.Abs(cameraDist.Length()) <= SHITTY_CAM_ZOOM_MIN_DIST) { zoom = Math.Min(zoom, 0); } OrbitCamDistance -= zoom * moveMult; //PointCameraToModel(); MoveCamera_OrbitCenterPoint(gamepad.ThumbSticks.Right.X, gamepad.ThumbSticks.Right.Y, 0, moveMult); } else { float camH = gamepad.ThumbSticks.Right.X * (float)1.5f * CameraTurnSpeedGamepad * (float)gameTime.ElapsedGameTime.TotalSeconds; float camV = gamepad.ThumbSticks.Right.Y * (float)1.5f * CameraTurnSpeedGamepad * (float)gameTime.ElapsedGameTime.TotalSeconds; if (isMoveLightKeyPressed) { LightRotation.Y += camH; LightRotation.X -= camV; } else { MoveCamera(gamepad.ThumbSticks.Left.X, gamepad.Triggers.Right - gamepad.Triggers.Left, gamepad.ThumbSticks.Left.Y, moveMult); CameraTransform.EulerRotation.Y -= camH; CameraTransform.EulerRotation.X += camV; } } } if (IsOrbitCam) { if (currentMouseClickL) { float x = 0; float z = 0; float y = 0; if (keyboard.IsKeyDown(Keys.W) && Math.Abs(cameraDist.Length()) > 0.1f) { z += 1; } if (keyboard.IsKeyDown(Keys.S)) { z -= 1; } if (keyboard.IsKeyDown(Keys.E)) { y += 1; } if (keyboard.IsKeyDown(Keys.Q)) { y -= 1; } if (keyboard.IsKeyDown(Keys.A)) { x -= 1; } if (keyboard.IsKeyDown(Keys.D)) { x += 1; } if (Math.Abs(cameraDist.Length()) <= SHITTY_CAM_ZOOM_MIN_DIST) { z = Math.Min(z, 0); } OrbitCamDistance -= z * moveMult; MoveCamera_OrbitCenterPoint(x, y, 0, moveMult); } else if (currentMouseClickR) { MoveCamera_OrbitCenterPoint_MouseDelta(mousePos, oldMouse); //Vector2 mouseDelta = mousePos - oldMouse; //MoveCamera_OrbitCenterPoint(-mouseDelta.X, mouseDelta.Y, 0, moveMult); } if (TaeInterop.ModelViewerWindowRect.Contains(mouse.Position)) { OrbitCamDistance -= (currentWheel - oldWheel) / 150f; } } else { float x = 0; float y = 0; float z = 0; if (keyboard.IsKeyDown(Keys.D)) { x += 1; } if (keyboard.IsKeyDown(Keys.A)) { x -= 1; } if (keyboard.IsKeyDown(Keys.E)) { y += 1; } if (keyboard.IsKeyDown(Keys.Q)) { y -= 1; } if (keyboard.IsKeyDown(Keys.W)) { z += 1; } if (keyboard.IsKeyDown(Keys.S)) { z -= 1; } MoveCamera(x, y, z, moveMult); } //if (isToggleAllSubmeshKeyPressed && !prev_isToggleAllSubmeshKeyPressed) //{ // game.ModelListWindow.TOGGLE_ALL_SUBMESH(); //} //if (isToggleAllDummyKeyPressed && !prev_isToggleAllDummyKeyPressed) //{ // game.ModelListWindow.TOGGLE_ALL_DUMMY(); //} //if (isToggleAllBonesKeyPressed && !prev_isToggleAllBonesKeyPressed) //{ // game.ModelListWindow.TOGGLE_ALL_BONES(); //} if (currentMouseClickL) { if (!oldMouseClickL) { //game.IsMouseVisible = false; oldMouse = mousePos; //Mouse.SetPosition(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); //mousePos = new Vector2(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); //oldMouseClick = true; //return; } else { //game.IsMouseVisible = false; Vector2 mouseDelta = mousePos - oldMouse; if (mouseDelta.LengthSquared() == 0) { return; } //Mouse.SetPosition(game.ClientBounds.X + game.ClientBounds.Width / 2, game.ClientBounds.Y + game.ClientBounds.Height / 2); float camH = mouseDelta.X * 0.5f * CameraTurnSpeedMouse * (float)gameTime.ElapsedGameTime.TotalSeconds; float camV = mouseDelta.Y * -0.5f * CameraTurnSpeedMouse * (float)gameTime.ElapsedGameTime.TotalSeconds; if (IsOrbitCam && !isMoveLightKeyPressed) { if (CameraTransform.EulerRotation.X >= MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { camV = Math.Min(camV, 0); } if (CameraTransform.EulerRotation.X <= -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT) { camV = Math.Max(camV, 0); } RotateCameraOrbit(camH, camV, MathHelper.PiOver2); //PointCameraToModel(); } else if (isMoveLightKeyPressed) { LightRotation.Y += camH; LightRotation.X -= camV; } else { CameraTransform.EulerRotation.Y -= camH; CameraTransform.EulerRotation.X += camV; } } //CameraTransform.Rotation.Z -= (float)Math.Cos(MathHelper.PiOver2 - CameraTransform.Rotation.Y) * camV; //RotateCamera(mouseDelta.Y * -0.01f * (float)moveMult, 0, 0, moveMult); //RotateCamera(0, mouseDelta.X * 0.01f * (float)moveMult, 0, moveMult); } else { if (IsOrbitCam) { RotateCameraOrbit(0, 0, MathHelper.PiOver2); } if (oldMouseClickL) { //Mouse.SetPosition((int)oldMouse.X, (int)oldMouse.Y); } //game.IsMouseVisible = true; } if (IsOrbitCam) { //DEBUG("Dist:" + ORBIT_CAM_DISTANCE); //DEBUG("AngX:" + CameraTransform.Rotation.X / MathHelper.Pi + " PI"); //DEBUG("AngY:" + CameraTransform.Rotation.Y / MathHelper.Pi + " PI"); //DEBUG("AngZ:" + CameraTransform.Rotation.Z / MathHelper.Pi + " PI"); CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP, MathHelper.PiOver2 * SHITTY_CAM_PITCH_LIMIT_FATCAT_CLAMP); OrbitCamDistance = Math.Max(OrbitCamDistance, SHITTY_CAM_ZOOM_MIN_DIST); var distanceVectorAfterMove = -Vector3.Transform(Vector3.Forward, CameraTransform.RotationMatrixXYZ * Matrix.CreateRotationY(MathHelper.Pi)) * new Vector3(-1, 1, 1); CameraTransform.Position = (OrbitCamCenter + (distanceVectorAfterMove * OrbitCamDistance)); } else { CameraTransform.EulerRotation.X = MathHelper.Clamp(CameraTransform.EulerRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); } LightRotation.X = MathHelper.Clamp(LightRotation.X, -MathHelper.PiOver2, MathHelper.PiOver2); oldWheel = currentWheel; //prev_isToggleAllSubmeshKeyPressed = isToggleAllSubmeshKeyPressed; //prev_isToggleAllDummyKeyPressed = isToggleAllDummyKeyPressed; //prev_isToggleAllBonesKeyPressed = isToggleAllBonesKeyPressed; oldClickType = currentClickType; oldMouseClickL = currentMouseClickL; oldMouseClickR = currentMouseClickR; oldMouseClickM = currentMouseClickM; oldOrbitCamToggleKeyPressed = isOrbitCamToggleKeyPressed; oldMouse = mousePos; }