public override bool Validate(XInputControllerState controller, WindowManager window) { if (controller.CurrentHoldTime.TotalSeconds >= this.Key && controller.HoldingButtons) { return(true); } return(false); }
public override bool Validate(XInputControllerState state, WindowManager window) { if (state.State.Gamepad.Buttons.ToString() .Equals(this.Key, StringComparison.OrdinalIgnoreCase)) { return(true); } return(false); }
public override bool Validate(XInputControllerState state, WindowManager window) { string winName = window.GetActiveProcessName(); if (winName.Equals(this.Key, StringComparison.OrdinalIgnoreCase)) { return(true); } return(false); }
public override bool Validate(XInputControllerState controller, WindowManager window) { var percent = Math.Round(((double)controller.State.Gamepad.RightTrigger / byte.MaxValue) * 100, 2); if (percent >= this.Key) { return(true); } return(false); }
/// <summary> /// /// </summary> /// <param name="state"></param> /// <param name="macro"></param> /// <returns></returns> private void RunMacro(XInputControllerState state, Macro macro) { Log.WriteLineColor("================================================================", ConsoleColor.DarkGray); Log.WriteAction(LogMarker.Macro, $"{macro.Name} macro conditions passed, executing {macro.Actions.Count} actions."); //foreach (var conLog in conditionChecks) //{ // Log.WriteAction(LogMarker.Condtn, conLog); //} for (int i = 0; i < macro.Actions.Count; i++) { var action = macro.Actions[i]; Log.WriteAction(LogMarker.Action, $"\t {i + 1}. {action.ToString()}"); action.Execute(Controller); } }
private bool ControllerEvent(XInputControllerState state) { // Get all macros with the ones with the highest condition count, these should execute first. var item = config.Macros.OrderByDescending(i => i.Conditions.Count); var running = config.Macros.SingleOrDefault(i => i.IsRunning); if (running != null) { // If the user stops holding the buttons stop the action. if (!state.HoldingButtons) { running.IsRunning = false; return(false); } // Check if its conditions are met again. bool allConditionsMet = true; foreach (var condition in running.Conditions) { bool currentConditionPassed = condition.Validate(state, windowManager); if (!currentConditionPassed) { allConditionsMet = false; } } if (allConditionsMet) { RunMacro(state, running); running.IsRunning = false; return(true); } else { return(false); } } // Find macros that match the current state and try to ignore others. foreach (var macro in item) { //// Is any macro already running, just execute it again since its already been validated. //var running = config.Macros.SingleOrDefault(i => i.IsRunning); //if (running != null) //{ // return RunMacro(state, running); //} bool allconditionsPassed = true; foreach (var condition in macro.Conditions) { bool currentConditionPassed = condition.Validate(state, windowManager); if (condition.GetType() == typeof(HoldCondition)) { // If the current condition is a hold condition, ignore validating it for now. } else if (!currentConditionPassed) { allconditionsPassed = false; } } // If all other conditions passed other than hold, lets mark it as running and check it again later. if (allconditionsPassed && macro.HasHoldCondition) { macro.IsRunning = true; return(false); } // If all conditions passed and it doesn't have a hold condition, lets execute it. if (allconditionsPassed) { RunMacro(state, macro); return(true); } } return(false); }
public virtual bool Validate(XInputControllerState controler, WindowManager window) { return(false); }