コード例 #1
0
 private static void ProcessPlayerAoe(GamepadButton button, bool state)
 {
     if (!_keyStates[(int)button])
     {
         if (button == Settings.Default.MemoryAoeConfirm)
         {
             WoWInput.SendMouseClick(MouseButton.Left);
             return;
         }
         if (button == Settings.Default.MemoryAoeCancel)
         {
             WoWInput.SendMouseClick(MouseButton.Right);
             return;
         }
     }
     ProcessInput(button, state);
 }
コード例 #2
0
        private static void InputWatcherThread()
        {
            while (_threadRunning)
            {
                var axisMovement = Settings.Default.SwapSticks
                    ? ControllerManager.GetRightAxis()
                    : ControllerManager.GetLeftAxis();
                var axisCursor = Settings.Default.SwapSticks
                    ? ControllerManager.GetLeftAxis()
                    : ControllerManager.GetRightAxis();

                ProcessMovement(axisMovement);

                ProcessCursor(axisCursor);


                if (ProcessManager.GameProcess != null &&
                    WoWReader.IsAttached && WoWReader.GameState)
                {
                    var foregroundWindow = GetForegroundWindow();
                    if (foregroundWindow == ProcessManager.GameProcess?.MainWindowHandle)
                    {
                        _setMouselook = false;
                    }

                    // Cancel mouselook when alt-tabbed
                    if (Settings.Default.MemoryAutoCancel && !_setMouselook && WoWReader.MouselookState &&
                        foregroundWindow != ProcessManager.GameProcess?.MainWindowHandle)
                    {
                        WoWInput.SendMouseClick(MouseButton.Right, true);
                        _setMouselook = true;
                    }

                    // Show/hide the overlay crosshair
                    if (Settings.Default.EnableOverlay && Settings.Default.EnableOverlayCrosshair)
                    {
                        // Show crosshair after mouselooking for 100ms
                        if (WoWReader.MouselookState && DateTime.Now >= _mouselookStarted + TimeSpan.FromMilliseconds(200) &&
                            !App.Overlay.CrosshairVisible && !_crosshairShowing)
                        {
                            App.Overlay.SetCrosshairState(true, _cursorX, _cursorY);
                            _crosshairShowing = true;
                        } // Otherwise hide crosshair
                        else if (!WoWReader.MouselookState && _crosshairShowing)
                        {
                            App.Overlay.SetCrosshairState(false);
                            _crosshairShowing = false;
                        }
                    }


                    // Check if mouselook is inactive
                    if (!WoWReader.MouselookState)
                    {
                        // Update last known cursor position
                        var cursor = Cursor.Position;
                        _cursorX = cursor.X;
                        _cursorY = cursor.Y;

                        // Check if we need to re-center the mouse cursor
                        if (Settings.Default.MemoryAutoCenter &&
                            foregroundWindow == ProcessManager.GameProcess?.MainWindowHandle &&
                            _mouselookStarted != DateTime.MinValue &&
                            DateTime.Now >=
                            _mouselookStarted + TimeSpan.FromMilliseconds(Settings.Default.MemoryAutoCenterDelay))
                        {
                            var windowRect = ProcessManager.GetClientRectangle();
                            Cursor.Position = new System.Drawing.Point(
                                windowRect.X + windowRect.Width / 2,
                                windowRect.Y + windowRect.Height / 2);
                        }

                        // Reset auto-center cooldown timer
                        _mouselookStarted = DateTime.MinValue;
                    }

                    // Check if mouselook is active
                    if (WoWReader.MouselookState)
                    {
                        // If so, start the cooldown timer
                        if (_mouselookStarted == DateTime.MinValue)
                        {
                            _mouselookStarted = DateTime.Now;
                        }

                        // If the timer has elapsed but mouselook is active, temporarily hide the crosshair
                        else if (Settings.Default.EnableOverlayCrosshair &&
                                 Settings.Default.MemoryAutoCenter &&
                                 DateTime.Now >= _mouselookStarted +
                                 TimeSpan.FromMilliseconds(Settings.Default.MemoryAutoCenterDelay) && _crosshairShowing &&
                                 App.Overlay.CrosshairVisible)
                        {
                            App.Overlay.SetCrosshairState(false);
                        }
                    }
                }

                Thread.Sleep(5);
            }
        }