Exemplo n.º 1
0
        private void HandleMouse()
        {
            // handle mouse
            MouseState mouseState    = Input.Instance.CurrentInput.MouseState;
            MouseState prevState     = Input.Instance.LastInput.MouseState;
            bool       mouseLeft     = mouseState.IsPressed(0);
            bool       mouseRight    = mouseState.IsPressed(1);
            bool       prevMouseLeft = prevState.IsPressed(0);
            bool       mouseHold     = mouseLeft && prevMouseLeft;

            // destroy / attack
            if (mouseLeft)
            {
                HandleMouseLeft(mouseHold);
            }
            else
            {
                DestroyProgress = 0f;
            }

            // use block / use item
            if (mouseRight)
            {
                HandleMouseRight();
            }
        }
Exemplo n.º 2
0
        public static void MouseButtonsInput(SimulatedGamePadState controller)
        {
            MouseState state = mouse.GetCurrentState();

            TRIGGER_LEFT_PRESSED  = state.IsPressed(0);
            TRIGGER_RIGHT_PRESSED = state.IsPressed(1);

            if (state.IsPressed(0))
            {
                controller.RightTrigger = 255;
            }
            else
            {
                if (!TranslateKeyboard.TRIGGER_RIGHT_PRESSED)
                {
                    controller.RightTrigger = 0;
                }
            }

            if (state.IsPressed(1))
            {
                controller.LeftTrigger = 255;
            }
            else
            {
                if (!TranslateKeyboard.TRIGGER_LEFT_PRESSED)
                {
                    controller.LeftTrigger = 0;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Checks keyboard and mouse input.
        /// </summary>
        public virtual void CheckInput(double deltaTime)
        {
            IList <Key> pressedKeys = keyboard.GetCurrentState().PressedKeys;

            if (pressedKeys.Contains(Key.W))
            {
                camera.MovePosition(MoveDirection.Forward, deltaTime);
            }
            else if (pressedKeys.Contains(Key.S))
            {
                camera.MovePosition(MoveDirection.Backward, deltaTime);
            }
            if (pressedKeys.Contains(Key.A))
            {
                camera.MovePosition(MoveDirection.Left, deltaTime);
            }
            else if (pressedKeys.Contains(Key.D))
            {
                camera.MovePosition(MoveDirection.Right, deltaTime);
            }

            MouseState firstMouseState  = mouse.GetCurrentState();
            MouseState secondMouseState = mouse.GetCurrentState();

            if (firstMouseState.IsPressed(0) && secondMouseState.IsPressed(0))
            {
                int differenceX = firstMouseState.X - secondMouseState.X;
                int differenceY = firstMouseState.Y - secondMouseState.Y;
                camera.MoveLook(new Vector2(differenceX, differenceY), 1.0f);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// intern helper to update view angles by mouse
        /// </summary>
        protected void UpdateThetaPhiFromMouse(float passedTimeSinceLastFrame, DPFCanvas canvas)
        {
            MouseState    stateMouse    = Mouse.GetCurrentState();
            KeyboardState stateKeyboard = Keyboard.GetCurrentState();

            // Left button pressed. Perform plane intersection.
            if (stateMouse.IsPressed(0))
            {
                System.Windows.Point mouse = System.Windows.Input.Mouse.GetPosition(canvas);
                _releaseMouseRelative.X = (float)((2 * mouse.X - canvas.ActualWidth) / canvas.ActualWidth);
                _releaseMouseRelative.Y = (float)((2 * mouse.Y - canvas.ActualHeight) / canvas.ActualHeight);

                //Console.WriteLine(_releaseMouseRelative.ToString());
                if (_setMouseRelative == null)
                {
                    _setMouseRelative = _releaseMouseRelative;
                }

                RedSea.Singleton.UpdateSelection();
            }
            // Mouse wheel pressed. Move camera.
            else if (_setMouseRelative != null)
            {
                RedSea.Singleton.EndSelection();
                _setMouseRelative = null;
            }

            if (stateMouse.IsPressed(2))
            {
                // mouse movement
                double deltaX = Cursor.Position.X - lastMouseX;
                double deltaY = Cursor.Position.Y - lastMouseY;
                phi   -= deltaX * rotationSpeed;
                theta -= deltaY * rotationSpeed;
            }
            else
            {
                //theta += (stateKeyboard.IsPressed(Key.UpArrow) ? rotationSpeed * passedTimeSinceLastFrame * 0.3f : 0.0f);
                //theta -= (stateKeyboard.IsPressed(Key.DownArrow) ? rotationSpeed * passedTimeSinceLastFrame * 0.3f : 0.0f);
                //phi -= (stateKeyboard.IsPressed(Key.RightArrow) ? rotationSpeed * passedTimeSinceLastFrame * 0.3f : 0.0f);
                //phi += (stateKeyboard.IsPressed(Key.LeftArrow) ? rotationSpeed * passedTimeSinceLastFrame * 0.3f : 0.0f);
            }

            lastMouseX = Cursor.Position.X;
            lastMouseY = Cursor.Position.Y;
        }
Exemplo n.º 5
0
        public override void Update()
        {
            if (mouse.Acquire().IsSuccess)
            {
                mousestate = mouse.GetCurrentState();

                oldTrigger = Trigger;
                Trigger    = mousestate.IsPressed((int)MouseObject.Button1);

                if (timer > 0)
                {
                    timer--;
                    pixelX = ((Cursor.Position.X - winPosX) * 256) / videoW;
                    if (pixelX < 0 || pixelX >= 256)
                    {
                        State = false;
                        return;
                    }
                    pixelY = ((Cursor.Position.Y - winPosY) * scanlinesCount) / videoH;
                    if (pixelY < 0 || pixelY >= scanlinesCount)
                    {
                        State = false;
                        return;
                    }
                    //System.Console.WriteLine(pixelX + ", " + pixelY);
                    for (int x = -15; x < 15; x++)
                    {
                        for (int y = -15; y < 15; y++)
                        {
                            if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < scanlinesCount && pixelY + y >= 0)
                            {
                                c     = NesEmu.GetPixel(pixelX + x, pixelY + y);
                                r     = (byte)(c >> 0x10);            // R
                                g     = (byte)(c >> 0x08);            // G
                                b     = (byte)(c >> 0x00);            // B
                                State = (r > 85 && g > 85 && b > 85); //bright color ?
                            }
                            if (State)
                            {
                                break;
                            }
                        }
                        if (State)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    State = false;
                }
                if (!Trigger && oldTrigger)
                {
                    timer = 6;
                }
            }
        }
Exemplo n.º 6
0
        //-----------------------------------------------------------------------
        public bool IsButtonDown(int index)
        {
            // Retrieve the mouse state only once per iteration to avoid getting
            // zeros on subsequent calls
            if (CurrentMouseState == null)
            {
                CurrentMouseState = MouseDevice.GetCurrentState();
            }

            return(CurrentMouseState.IsPressed(index));
        }
Exemplo n.º 7
0
        public static void MouseButtonsInput(X360Controller controller)
        {
            MouseState state = mouse.GetCurrentState();

            if (state.IsPressed(0))
            {
                controller.RightTrigger = 255;
            }
            else
            {
                controller.RightTrigger = 0;
            }

            if (state.IsPressed(1))
            {
                controller.LeftTrigger = 255;
            }
            else
            {
                controller.LeftTrigger = 0;
            }
        }
Exemplo n.º 8
0
        public override void Update()
        {
            if (mouse.Acquire().IsSuccess)
            {
                mousestate = mouse.GetCurrentState();

                oldTrigger = Trigger;
                Trigger = mousestate.IsPressed((int)MouseObject.Button1);

                if (timer > 0)
                {
                    timer--;
                    pixelX = ((Cursor.Position.X - winPosX) * 256) / videoW;
                    if (pixelX < 0 || pixelX >= 256)
                    {
                        State = false;
                        return;
                    }
                    pixelY = ((Cursor.Position.Y - winPosY) * scanlinesCount) / videoH;
                    if (pixelY < 0 || pixelY >= scanlinesCount)
                    {
                        State = false;
                        return;
                    }
                    //System.Console.WriteLine(pixelX + ", " + pixelY);
                    for (int x = -15; x < 15; x++)
                    {
                        for (int y = -15; y < 15; y++)
                        {
                            if (pixelX + x < 256 && pixelX + x >= 0 && pixelY + y < scanlinesCount && pixelY + y >= 0)
                            {
                                c = NesEmu.GetPixel(pixelX + x, pixelY + y);
                                r = (byte)(c >> 0x10); // R
                                g = (byte)(c >> 0x08); // G
                                b = (byte)(c >> 0x00);  // B
                                State = (r > 85 && g > 85 && b > 85);//bright color ?
                            }
                            if (State)
                                break;
                        }
                        if (State)
                            break;
                    }
                }
                else
                    State = false;
                if (!Trigger && oldTrigger)
                    timer = 6;
            }
        }
Exemplo n.º 9
0
        public bool GetButtonPress(char button, bool ignorePressStamp = false)
        {
            if (!_mouseState.IsPressed(button))
            {
                return(false);
            }

            var pressed = true;

            if (!ignorePressStamp)
            {
                if (_buttonPressStamp[button] == _pressStamp - 1 || _buttonPressStamp[button] == _pressStamp)
                {
                    pressed = false;
                }
            }
            _buttonPressStamp[button] = _pressStamp;

            return(pressed);
        }
Exemplo n.º 10
0
        private bool Tracking(MouseState mouseState, MouseButton mouseButton)
        {
            if (!mouseState.IsPressed(mouseButton))
            {
                _tracking[mouseButton] = false;

                return(false);
            }

            if (!_tracking[mouseButton])
            {
                _tracking[mouseButton] = true;

                _previousCoordinates[mouseButton] = new Coordinates(mouseState);

                return(false);
            }

            return(true);
        }
Exemplo n.º 11
0
        void ReadImmediateData()
        {
            if (mouse.Acquire().IsFailure)
            {
                return;
            }

            if (mouse.Poll().IsFailure)
            {
                return;
            }

            MouseState state = mouse.GetCurrentState();

            if (Result.Last.IsFailure)
            {
                return;
            }

            StringBuilder data = new StringBuilder();

            data.AppendFormat(CultureInfo.CurrentCulture, "(X={0} Y={1} Z={2})", state.X, state.Y, state.Z);
            for (int i = 0; i < 8; i++)
            {
                data.Append(" B");
                data.Append(i);
                data.Append("=");
                if (state.IsPressed(i))
                {
                    data.Append("1");
                }
                else
                {
                    data.Append("0");
                }
            }

            dataBox.Text = data.ToString();
        }
Exemplo n.º 12
0
 public bool IsMouseButtonPressed(int button)
 {
     return(_mouseStateCurrent.IsPressed(button));
 }
Exemplo n.º 13
0
 public bool WasMouseButtonPressed(int button)
 {
     return(_mouseStateLast.IsPressed(button));
 }
Exemplo n.º 14
0
 private bool prevLeftPressed()
 {
     return(prevMouseState.IsPressed(0));
 }
Exemplo n.º 15
0
        private MouseButtonState GetMouseButtonState(MouseState mouseState, DIButton button)
        {
            if (mouseState == null)
                return MouseButtonState.Released;

            return mouseState.IsPressed((int)button) ? MouseButtonState.Pressed : MouseButtonState.Released;
        }
Exemplo n.º 16
0
 public static bool IsLeftClickTrigger()
 {
     return((s_thisMouseState.IsPressed(0)) && (s_lastFrameMouseState.IsReleased(0)));
 }
Exemplo n.º 17
0
        private static void processPressedKeys()
        {
            try
            {
                if (A_Collection.D3Client.Window.isForeground && !A_Collection.D3UI.isChatting)
                {
                    if (Window_Main.keyboard == null)
                    {
                        return;
                    }

                    KeyboardState deviceState = Window_Main.keyboard.GetCurrentState();

                    lock (A_Collection.Hotkeys._PressedKeys)
                        A_Collection.Hotkeys._PressedKeys = deviceState.PressedKeys.ToList();



                    //collect pressed mouse buttons
                    lock (A_Collection.Hotkeys._pressedMouseButtons)
                    {
                        MouseState mouseState = Window_Main.mouse.GetCurrentState();

                        List <MouseObject> _tempList = new List <MouseObject>();
                        foreach (int mouseKeyCode in Enum.GetValues(typeof(MouseObject)))
                        {
                            if (mouseKeyCode < (int)MouseObject.XAxis)
                            {
                                if (mouseState.IsPressed(mouseKeyCode))
                                {
                                    _tempList.Add((MouseObject)mouseKeyCode);
                                }
                            }
                        }

                        A_Collection.Hotkeys._pressedMouseButtons = _tempList;
                    }


                    foreach (var hotkey in A_Collection.Hotkeys.D3Helper_Hotkeys)
                    {
                        if (hotkey.Key.Key == Key.Unknown)
                        {
                            continue;
                        }

                        if (A_Collection.Hotkeys.lastprocessedHotkey != hotkey.Key.Key)
                        {
                            bool isPressed = true;

                            foreach (var modifier in hotkey.Key.Modifiers)
                            {
                                if (!deviceState.IsPressed(modifier))
                                {
                                    isPressed = false;
                                }
                            }

                            if (!deviceState.IsPressed(hotkey.Key.Key))
                            {
                                isPressed = false;
                            }

                            if (!isPressed)
                            {
                                continue;
                            }

                            switch (hotkey.Value)
                            {
                            case "slot1":
                                A_Tools.T_ExternalFile.AutoCastOverrides.ChangeOverrides(0);
                                break;

                            case "slot2":
                                A_Tools.T_ExternalFile.AutoCastOverrides.ChangeOverrides(1);
                                break;

                            case "slot3":
                                A_Tools.T_ExternalFile.AutoCastOverrides.ChangeOverrides(2);
                                break;

                            case "slot4":
                                A_Tools.T_ExternalFile.AutoCastOverrides.ChangeOverrides(3);
                                break;

                            case "slotrmb":
                                A_Tools.T_ExternalFile.AutoCastOverrides.ChangeOverrides(4);
                                break;

                            case "slotlmb":
                                A_Tools.T_ExternalFile.AutoCastOverrides.ChangeOverrides(5);
                                break;

                            case "editmode":
                                if (A_Collection.Me.GearSwap.editModeEnabled)
                                {
                                    A_Collection.Me.GearSwap.editModeEnabled = false;
                                }
                                else
                                {
                                    A_Collection.Me.GearSwap.editModeEnabled = true;
                                }
                                break;

                            case "swap1":
                                A_Collection.Me.GearSwap.Selected_SwapId = 1;

                                if (!A_Collection.Me.GearSwap.editModeEnabled && !A_Collection.D3UI.isChatting)
                                {
                                    A_Handler.GearSwap.GearSwap.tryGearSwap();
                                }
                                break;

                            case "swap2":
                                A_Collection.Me.GearSwap.Selected_SwapId = 2;

                                if (!A_Collection.Me.GearSwap.editModeEnabled && !A_Collection.D3UI.isChatting)
                                {
                                    A_Handler.GearSwap.GearSwap.tryGearSwap();
                                }
                                break;

                            case "swap3":
                                A_Collection.Me.GearSwap.Selected_SwapId = 3;

                                if (!A_Collection.Me.GearSwap.editModeEnabled && !A_Collection.D3UI.isChatting)
                                {
                                    A_Handler.GearSwap.GearSwap.tryGearSwap();
                                }
                                break;

                            case "swap4":
                                A_Collection.Me.GearSwap.Selected_SwapId = 4;

                                if (!A_Collection.Me.GearSwap.editModeEnabled && !A_Collection.D3UI.isChatting)
                                {
                                    A_Handler.GearSwap.GearSwap.tryGearSwap();
                                }
                                break;

                            case "paragonpoints1":
                                if (!A_Collection.Me.ParagonPointSpender.Is_SpendingPoints)
                                {
                                    A_Collection.Me.ParagonPointSpender.SelectedParagonPoints_Setup = 1;

                                    A_Handler.ParagonPointSpender.ParagonPointSpender.Set_ParagonPoints();
                                }
                                break;

                            case "paragonpoints2":
                                if (!A_Collection.Me.ParagonPointSpender.Is_SpendingPoints)
                                {
                                    A_Collection.Me.ParagonPointSpender.SelectedParagonPoints_Setup = 2;

                                    A_Handler.ParagonPointSpender.ParagonPointSpender.Set_ParagonPoints();
                                }
                                break;

                            case "paragonpoints3":
                                if (!A_Collection.Me.ParagonPointSpender.Is_SpendingPoints)
                                {
                                    A_Collection.Me.ParagonPointSpender.SelectedParagonPoints_Setup = 3;

                                    A_Handler.ParagonPointSpender.ParagonPointSpender.Set_ParagonPoints();
                                }
                                break;

                            case "paragonpoints4":
                                if (!A_Collection.Me.ParagonPointSpender.Is_SpendingPoints)
                                {
                                    A_Collection.Me.ParagonPointSpender.SelectedParagonPoints_Setup = 4;

                                    A_Handler.ParagonPointSpender.ParagonPointSpender.Set_ParagonPoints();
                                }
                                break;

                            case "autogamble":
                                Properties.Settings.Default.AutoGambleBool =
                                    !Properties.Settings.Default.AutoGambleBool;
                                Properties.Settings.Default.Save();
                                break;

                            case "skillbuild1":
                                if (!A_Collection.Me.SkillBuilds.Is_SwapingBuild)
                                {
                                    A_Collection.Me.SkillBuilds.SelectedSkillBuild = 0;

                                    A_Handler.SkillBuildSwap.SkillBuildSwap.DoSwap();
                                }
                                break;

                            case "skillbuild2":
                                if (!A_Collection.Me.SkillBuilds.Is_SwapingBuild)
                                {
                                    A_Collection.Me.SkillBuilds.SelectedSkillBuild = 1;

                                    A_Handler.SkillBuildSwap.SkillBuildSwap.DoSwap();
                                }
                                break;

                            case "skillbuild3":
                                if (!A_Collection.Me.SkillBuilds.Is_SwapingBuild)
                                {
                                    A_Collection.Me.SkillBuilds.SelectedSkillBuild = 2;

                                    A_Handler.SkillBuildSwap.SkillBuildSwap.DoSwap();
                                }
                                break;

                            case "skillbuild4":
                                if (!A_Collection.Me.SkillBuilds.Is_SwapingBuild)
                                {
                                    A_Collection.Me.SkillBuilds.SelectedSkillBuild = 3;

                                    A_Handler.SkillBuildSwap.SkillBuildSwap.DoSwap();
                                }
                                break;

                            case "autopick":
                                if (!A_Handler.AutoPick.AutoPick.IsPicking)
                                {
                                    A_Handler.AutoPick.AutoPick.DoPickup();
                                }
                                break;

                            case "autocube_upgraderare":
                                if (!A_Handler.AutoCube.UpgradeRare.IsUpgrading_Rare)
                                {
                                    A_Handler.AutoCube.UpgradeRare.DoUpgrade();
                                }
                                break;

                            case "autocube_convertmaterial":
                                if (!A_Handler.AutoCube.ConvertMaterial.IsConvertingMaterial)
                                {
                                    // normal, magic, rare
                                    A_Handler.AutoCube.ConvertMaterial.DoConvert(Properties.Settings.Default.ConvertMaterialFrom, Properties.Settings.Default.ConvertMaterialTo);
                                }
                                break;
                            }

                            A_Collection.Hotkeys.lastprocessedHotkey = hotkey.Key.Key;
                            lastHotkeyProcess = DateTime.Now;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                A_Handler.Log.Exception.addExceptionLogEntry(e, A_Enums.ExceptionThread.ECollector);
            }
        }
Exemplo n.º 18
0
 private bool leftPressed()
 {
     return(mouseState.IsPressed(0));
 }