private static void DS4TouchpadButtonDown(object sender, TouchpadEventArgs args) { if (!Settings.Default.EnableTouchpad) { return; } // Ignore touchpad if disabled during mouselook // Ignore touchpad if disabled during mouselook if (Settings.Default.MemoryTouchpadCursorOnly && WoWReader.IsAttached && WoWReader.GameState && WoWReader.MouselookState) { return; } switch (Settings.Default.TouchpadMode) { case 0: WoWInput.SendMouseDown(args.touches.Last().hwX < (1920 / 2) ? MouseButton.Left : MouseButton.Right); break; case 1: WoWInput.SendKeyDown(args.touches.Last().hwX < (1920 / 2) ? BindManager.GetKey(GamepadButton.CenterLeft) : BindManager.GetKey(GamepadButton.CenterRight)); break; } }
private static bool ProcessButton(GamepadButton button, bool state) { if (_keyStates[(int)button] != state) { if (state) { WoWInput.SendKeyDown(BindManager.GetKey(button)); } else { WoWInput.SendKeyUp(BindManager.GetKey(button)); } _keyStates[(int)button] = state; } return(state); }
private static void DS4TouchpadButtonDown(object sender, TouchpadEventArgs args) { if (!Settings.Default.EnableTouchpad) { return; } switch (Settings.Default.TouchpadMode) { case 0: WoWInput.SendMouseDown(args.touches.Last().hwX < (1920 / 2) ? MouseButton.Left : MouseButton.Right); break; case 1: WoWInput.SendKeyDown(args.touches.Last().hwX < (1920 / 2) ? BindManager.GetKey(GamepadButton.CenterLeft) : BindManager.GetKey(GamepadButton.CenterRight)); break; } }
private static void ProcessInput(GamepadButton button, bool state) { // Do left/right mouse buttons if (button == GamepadButton.LeftStick) { if (state) { WoWInput.SendMouseDown(MouseButton.Left); } else { WoWInput.SendMouseUp(MouseButton.Left); } } else if (button == GamepadButton.RightStick) { if (state) { WoWInput.SendMouseDown(MouseButton.Right); } else { WoWInput.SendMouseUp(MouseButton.Right); } } // Do other buttons if (_keyStates[(int)button] != state) { if (state) { WoWInput.SendKeyDown(BindManager.GetKey(button)); } else { WoWInput.SendKeyUp(BindManager.GetKey(button)); } } _keyStates[(int)button] = state; }
public static void WriteBinds() { if (ProcessManager.GameProcess == null) { return; } // Attempt to locate WoWmapper.lua var addonPath = Path.GetDirectoryName(ProcessManager.GameProcess.MainModule.FileName); if (addonPath == null) { return; } var luaFile = Path.Combine(addonPath, "Interface\\AddOns\\ConsolePort\\Controllers\\WoWmapper.lua"); if (!File.Exists(luaFile)) { return; } // If export is disabled, write blank file if (!Settings.Default.ExportBindings) { Log.WriteLine("Clearing ConsolePort bindings at {0}", luaFile); File.WriteAllText(luaFile, "return"); return; } // Get last modify time and see if it needs updating var fileInfo = new FileInfo(luaFile); if (fileInfo.LastWriteTime >= Settings.Default.BindingsModified) { return; } Log.WriteLine("Writing ConsolePort bind configuration to {0}", luaFile); var templateStreamInfo = Application.GetResourceStream(new Uri("pack://application:,,,/ConsolePort/WoWmapper.lua")); var templateStream = templateStreamInfo.Stream; var templateReader = new StreamReader(templateStream); var bindDict = new BindDictionary(); try { using (var fileStream = new FileStream(luaFile, FileMode.Create)) using (var fileWriter = new StreamWriter(fileStream)) while (!templateReader.EndOfStream) { var templateLine = templateReader.ReadLine(); if (templateLine == null) { break; } if (!templateLine.Contains('<') && !templateLine.Contains('>')) { fileWriter.WriteLine(templateLine); continue; } var templateKey = templateLine.Substring(templateLine.IndexOf('<') + 1); templateKey = templateKey.Substring(0, templateKey.IndexOf('>')); try { var bindValue = bindDict.GetBindKey(templateKey); fileWriter.WriteLine(templateLine.Replace("<" + templateKey + ">", bindValue)); } catch { fileWriter.WriteLine(templateLine); } } App.Overlay.PopupNotification(new OverlayNotification() { Content = $"Your ConsolePort settings have been updated. Reload your user interface to activate your changes.", Header = "Settings updated", Duration = 10000, UniqueID = "CP_UPDATED" }); new Task(() => { WoWInput.SendKeyDown(Key.LeftAlt, true); WoWInput.SendKeyDown(Key.LeftCtrl, true); WoWInput.SendKeyDown(Key.LeftShift, true); Thread.Sleep(50); WoWInput.SendKeyDown(Key.F12, true); Thread.Sleep(50); WoWInput.SendKeyUp(Key.F12, true); WoWInput.SendKeyUp(Key.LeftShift, true); WoWInput.SendKeyUp(Key.LeftCtrl, true); WoWInput.SendKeyUp(Key.LeftAlt, true); }).Start(); } catch { } }
private static void ProcessCharacterMenu(GamepadButton button, bool state) { switch (button) { case GamepadButton.LFaceUp: if (state && !_keyStates[(int)button]) { WoWInput.SendKeyDown(Key.Up); } if (!state && _keyStates[(int)button]) { WoWInput.SendKeyUp(Key.Up); } break; case GamepadButton.LFaceDown: if (state && !_keyStates[(int)button]) { WoWInput.SendKeyDown(Key.Down); } if (!state && _keyStates[(int)button]) { WoWInput.SendKeyUp(Key.Down); } break; case GamepadButton.RFaceDown: if (state && !_keyStates[(int)button]) { WoWInput.SendKeyDown(Key.Enter); } if (!state && _keyStates[(int)button]) { WoWInput.SendKeyUp(Key.Enter); } break; case GamepadButton.CenterMiddle: if (state && !_keyStates[(int)button]) { WoWInput.SendKeyDown(Key.Escape); } if (!state && _keyStates[(int)button]) { WoWInput.SendKeyUp(Key.Escape); } break; } // Do left/right mouse buttons if (button == GamepadButton.LeftStick) { if (state) { WoWInput.SendMouseDown(MouseButton.Left); } else { WoWInput.SendMouseUp(MouseButton.Left); } } else if (button == GamepadButton.RightStick) { if (state) { WoWInput.SendMouseDown(MouseButton.Right); } else { WoWInput.SendMouseUp(MouseButton.Right); } } _keyStates[(int)button] = state; }
private static void ProcessMovement(Point axis) { var sendLeft = -axis.X > Settings.Default.MovementThreshold; var sendRight = axis.X > Settings.Default.MovementThreshold; var sendUp = -axis.Y > Settings.Default.MovementThreshold; var sendDown = axis.Y > Settings.Default.MovementThreshold; var strength = Math.Sqrt(axis.X * axis.X + axis.Y * axis.Y); if (false && Settings.Default.MemoryAutoWalk && // AUTO WALK DISABLED WoWReader.IsAttached && WoWReader.GameState) { var moveState = WoWReader.MovementState; if (moveState == 0 || moveState == 1) { if (strength < Settings.Default.WalkThreshold && strength >= Settings.Default.MovementThreshold && moveState == 0) // Activate Walk { WoWInput.SendKeyDown(Key.Divide); WoWInput.SendKeyUp(Key.Divide); _stopWalk = false; } else if (strength >= Settings.Default.WalkThreshold && moveState == 1) // Deactivate walk, start run { WoWInput.SendKeyDown(Key.Divide); WoWInput.SendKeyUp(Key.Divide); } else if (strength < Settings.Default.MovementThreshold && !_stopWalk && moveState == 1) // Deactivate walk, stop moving { WoWInput.SendKeyDown(Key.Divide); WoWInput.SendKeyUp(Key.Divide); _stopWalk = true; } } } if (sendLeft) { if (!_keyStates[(int)GamepadButton.LeftStickLeft]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickLeft)); _keyStates[(int)GamepadButton.LeftStickLeft] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickLeft]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickLeft)); _keyStates[(int)GamepadButton.LeftStickLeft] = false; } } if (sendRight) { if (!_keyStates[(int)GamepadButton.LeftStickRight]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickRight)); _keyStates[(int)GamepadButton.LeftStickRight] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickRight]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickRight)); _keyStates[(int)GamepadButton.LeftStickRight] = false; } } if (sendUp) { if (!_keyStates[(int)GamepadButton.LeftStickUp]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickUp)); _keyStates[(int)GamepadButton.LeftStickUp] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickUp]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickUp)); _keyStates[(int)GamepadButton.LeftStickUp] = false; } } if (sendDown) { if (!_keyStates[(int)GamepadButton.LeftStickDown]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickDown)); _keyStates[(int)GamepadButton.LeftStickDown] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickDown]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickDown)); _keyStates[(int)GamepadButton.LeftStickDown] = false; } } }
private static void ProcessMovement(Point axis) { var sendLeft = -axis.X > Settings.Default.MovementThreshold; var sendRight = axis.X > Settings.Default.MovementThreshold; var sendUp = -axis.Y > Settings.Default.MovementThreshold; var sendDown = axis.Y > Settings.Default.MovementThreshold; var strength = Math.Sqrt(axis.X * axis.X + axis.Y * axis.Y); if (sendLeft) { if (!_keyStates[(int)GamepadButton.LeftStickLeft]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickLeft)); _keyStates[(int)GamepadButton.LeftStickLeft] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickLeft]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickLeft)); _keyStates[(int)GamepadButton.LeftStickLeft] = false; } } if (sendRight) { if (!_keyStates[(int)GamepadButton.LeftStickRight]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickRight)); _keyStates[(int)GamepadButton.LeftStickRight] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickRight]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickRight)); _keyStates[(int)GamepadButton.LeftStickRight] = false; } } if (sendUp) { if (!_keyStates[(int)GamepadButton.LeftStickUp]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickUp)); _keyStates[(int)GamepadButton.LeftStickUp] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickUp]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickUp)); _keyStates[(int)GamepadButton.LeftStickUp] = false; } } if (sendDown) { if (!_keyStates[(int)GamepadButton.LeftStickDown]) { WoWInput.SendKeyDown(BindManager.GetKey(GamepadButton.LeftStickDown)); _keyStates[(int)GamepadButton.LeftStickDown] = true; } } else { if (_keyStates[(int)GamepadButton.LeftStickDown]) { WoWInput.SendKeyUp(BindManager.GetKey(GamepadButton.LeftStickDown)); _keyStates[(int)GamepadButton.LeftStickDown] = false; } } }