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); Thread.Sleep(5); } }
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); } }
private void FeedbackThread() { long lastHealth = 0; long lastMax = 0; byte lastLevel = 0; while (_feedbackThread.ThreadState != ThreadState.Aborted) { if (WoWReader.IsAttached && WoWReader.GameState && ControllerManager.ActiveController != null) { var playerHealth = WoWReader.PlayerHealth; if (playerHealth != null) { // Check player health defecit var maxHealth = playerHealth.Item2; var currentHealth = playerHealth.Item1; var healthLost = lastHealth - currentHealth; if (Settings.Default.MemoryVibrationDamage && healthLost > 0 && maxHealth <= lastMax && maxHealth > 0) { // Player has taken damage var damagePercent = (float)healthLost / lastHealth; var leftStrength = (byte)(damagePercent * 200 + 55); var rightStrength = (byte)(damagePercent * 200 + 55); var duration = (int)(damagePercent * 2500 + 500); Console.WriteLine($"Rumble {leftStrength} {rightStrength} {duration}"); ControllerManager.SendRumble(leftStrength, rightStrength, duration); } else if (Settings.Default.MemoryVibrationHealing && healthLost < 0 && lastHealth > 0) { if (-healthLost > (maxHealth / 25)) { healthLost = -(maxHealth / 25); } // Player was healed var damagePercent = (float)-healthLost / maxHealth; var leftStrength = (byte)(damagePercent * 100 + 20); var rightStrength = (byte)(damagePercent * 100 + 35); var duration = (int)(damagePercent * 1500 + 500); Console.WriteLine($"Rumble {leftStrength} {rightStrength} {duration}"); ControllerManager.SendRumble(leftStrength, rightStrength, duration); } lastHealth = currentHealth; lastMax = maxHealth; // Lightbar control //var ds4 = ControllerManager.ActiveController.UnderlyingController as DS4Device; //if (ds4 != null) //{ // var healthPercent = ((float)currentHealth / maxHealth) * 100; // if (healthPercent >= 90) // { // ds4.LightBarColor = new DS4Color(Color.Green); // ds4.LightBarOnDuration = 255; // ds4.LightBarOffDuration = 0; // } // else // { // ds4.LightBarColor = new DS4Color(Color.Red); // ds4.LightBarOnDuration = 255; // ds4.LightBarOffDuration = 0; // } //} } } Thread.Sleep(5); } }