public InputEvent.Status Run(bool firstRun, double elapsed, int analogVal, ref Xim.Input input, ref Xim.Input startState) { analogVal -= (int)Xim.Stick.Max; if ((this.analog & Joystick.AnalogFlags.Invert) != 0) analogVal = -analogVal; if (deadzone != 0 && analogVal != 0) { if ((this.analog & Joystick.AnalogFlags.Scale) != 0) { analogVal *= (int)(Xim.Stick.Max) - deadzone / (int)(Xim.Stick.Max); } analogVal += Math.Sign(analogVal) * deadzone; } if (button == Xim.Analog.LeftTrigger || button == Xim.Analog.RightTrigger) { if ((this.analog & Joystick.AnalogFlags.Scale) != 0) { analogVal += (int)Xim.Stick.Max; analogVal = (int)((double)analogVal * 0.5); } if (analogVal < 0) analogVal = 0; } Xim.AddAnalogValue(button, analogVal, ref input); return Status.Running; }
public void UpdateOutputView(Xim.Input input) { this.cbRawA.Checked = input.A == Xim.ButtonState.Pressed; this.cbRawB.Checked = input.B == Xim.ButtonState.Pressed; this.cbRawY.Checked = input.Y == Xim.ButtonState.Pressed; this.cbRawX.Checked = input.X == Xim.ButtonState.Pressed; this.cbRawStart.Checked = input.Start == Xim.ButtonState.Pressed; this.cbRawBack.Checked = input.Back == Xim.ButtonState.Pressed; this.cbRawGuide.Checked = input.Guide == Xim.ButtonState.Pressed; this.cbRawDDown.Checked = input.Down == Xim.ButtonState.Pressed; this.cbRawDUp.Checked = input.Up == Xim.ButtonState.Pressed; this.cbRawDLeft.Checked = input.Left == Xim.ButtonState.Pressed; this.cbRawDRight.Checked = input.Right == Xim.ButtonState.Pressed; this.cbRawRBumper.Checked = input.RightBumper == Xim.ButtonState.Pressed; this.cbRawLBumper.Checked = input.LeftBumper == Xim.ButtonState.Pressed; this.cbRawRightStick.Checked = input.RightStick == Xim.ButtonState.Pressed; this.cbRawLeftStick.Checked = input.LeftStick == Xim.ButtonState.Pressed; this.tbRawLTrigger.Text = input.LeftTrigger.ToString(); this.tbRawRTrigger.Text = input.RightTrigger.ToString(); this.tbRawLX.Text = input.LeftStickX.ToString(); this.tbRawLY.Text = input.LeftStickY.ToString(); this.tbRawRX.Text = input.RightStickX.ToString(); this.tbRawRY.Text = input.RightStickY.ToString(); this.leftStick.Location = new System.Drawing.Point( (int)this.drawSticksCenter.X + (int)(((double)input.LeftStickX / (short)Xim.Stick.Max) * (this.drawSticksSize / 2)) , (int)this.drawSticksCenter.Y - (int)(((double)input.LeftStickY / (short)Xim.Stick.Max) * (this.drawSticksSize / 2))); this.rightStick.Location = new System.Drawing.Point( (int)this.drawSticksCenter.X + (int)(((double)input.RightStickX / (short)Xim.Stick.Max) * (this.drawSticksSize / 2)) , (int)this.drawSticksCenter.Y - (int)(((double)input.RightStickY / (short)Xim.Stick.Max) * (this.drawSticksSize / 2))); }
protected bool Run(double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { Stack<InputEvent> finishedEvents = new Stack<InputEvent>(); foreach (InputEvent inputEvent in m_currentEvents) { if (inputEvent.Run(false/*firstRun*/, elapsed, keyStillPressed, ref input, ref startState ) == InputEvent.Status.Complete ) { finishedEvents.Push(inputEvent); } } while (finishedEvents.Count!=0) { m_currentEvents.Remove(finishedEvents.Pop()); } if (m_blocking) { InputEvent.Status status = m_blockingEvent.Run(false/*firstRun*/, elapsed, keyStillPressed, ref input, ref startState); switch (status) { case InputEvent.Status.Complete: m_blocking = false; break; case InputEvent.Status.Running: m_blocking = false; m_currentEvents.Add(m_blockingEvent.Clone()); break; } } if (!m_blocking) { while (m_futureEventIndex < m_futureEvents.Count) { InputEvent nextEvent = m_futureEvents[m_futureEventIndex]; InputEvent.Status status = nextEvent.Run(true/*firstRun*/, elapsed, keyStillPressed, ref input, ref startState); m_futureEventIndex++; if (status == InputEvent.Status.Blocking) { m_blockingEvent = nextEvent.Clone(); m_blocking = true; break; } else if (status == InputEvent.Status.Running) { m_currentEvents.Add(nextEvent.Clone()); } else if (status == InputEvent.Status.Break) { m_futureEventIndex = m_futureEvents.Count; } } } return !(m_currentEvents.Count == 0 && m_futureEventIndex >= m_futureEvents.Count); }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { if (keyStillPressed) { Xim.SetButtonState(m_button, Xim.ButtonState.Pressed, ref input); } return keyStillPressed ? Status.Running : Status.Complete; }
public HoldEvent(Xim.Button button) { m_button = button; }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { m_stillPressed = m_stillPressed && Xim.GetButtonState(button, ref input) == Xim.ButtonState.Pressed; return base.Run(elapsed, m_stillPressed, ref input, ref startState); }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { m_var.Value = !(bool)m_var.Value; return Status.Complete; }
public ToggleEvent(Xim.Button button) { m_button = button; }
public XInputAnalogEventHandler(Xim.Analog button, AnalogEvent inputEvent) : base(null) { this.button = button; this.inputEvent = inputEvent; }
/* * Return value: True if the event is finished. * */ public abstract Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState);
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { Xim.SetButtonState(m_button, Xim.ButtonState.Pressed, ref input); if (!firstRun) m_elapsed += elapsed; return m_elapsed > (double)(int)buttonDownTime.Value ? InputEvent.Status.Complete : InputEvent.Status.Running; }
public ButtonEvent(Xim.Button button) { m_button = button; VarManager.Instance.GetVar(VarManager.Names.ButtonDownTime, out buttonDownTime); }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { return keyStillPressed? Status.Complete : Status.Break; }
public abstract bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState);
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { m_stillPressed = m_stillPressed && pressedState.xinputState.IsButtonDown(this.button); return base.Run(elapsed, m_stillPressed, ref input, ref startState); }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { int analogVal = 0; float controllerValue = 0; switch (button) { case Xim.Analog.LeftStickX: controllerValue = pressedState.xinputState.ThumbSticks.Left.X; break; case Xim.Analog.LeftStickY: controllerValue = pressedState.xinputState.ThumbSticks.Left.Y; break; case Xim.Analog.LeftTrigger: controllerValue = pressedState.xinputState.Triggers.Left; break; case Xim.Analog.RightStickX: controllerValue = pressedState.xinputState.ThumbSticks.Right.X; break; case Xim.Analog.RightStickY: controllerValue = pressedState.xinputState.ThumbSticks.Right.Y; break; case Xim.Analog.RightTrigger: controllerValue = pressedState.xinputState.Triggers.Right; break; default: return false; } analogVal = (int)(controllerValue * (int)Xim.Stick.Max + (int)Xim.Stick.Max); inputEvent.Run(false, elapsed, analogVal, ref input, ref startState); return true; }
public override Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { if (firstRun) { m_oldValue = m_var.Value; m_var.Value = m_newValue; } if (!keyStillPressed) { m_var.Value = m_oldValue; } return keyStillPressed ? Status.Running : Status.Complete; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { ConfigManager.Instance.LoadConfig(m_filePath); return Status.Complete; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { // This should never get hit. return Status.Complete; }
public RapidEvent(Xim.Button button, double delay) { this.button = button; this.delay = delay; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { CommandParser.Instance.ParseLine(this.cmdLine); return Status.Complete; }
public override bool Run(double elapsed, PressedState pressedState, ref Xim.Input input, ref Xim.Input startState) { m_stillPressed = m_stillPressed && pressedState.mouseButtons.Contains(m_button); return base.Run(elapsed, m_stillPressed, ref input, ref startState); }
public PressEvent(Xim.Button button, Xim.ButtonState state) { m_button = button; m_state = state; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { InfoTextManager.Instance.WriteLine(m_echo); return Status.Complete; }
public override Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { if (keyStillPressed) { if (firstRun) { Xim.ToggleButtonState(this.button, ref input); //Xim.ToggleButtonState(this.button, ref startState); } else { this.elapsed += elapsed; if (this.elapsed > delay) { this.elapsed = this.elapsed - delay; Xim.ToggleButtonState(this.button, ref startState); } } } else { Xim.SetButtonState(this.button, Xim.ButtonState.Released, ref startState); } return keyStillPressed ? Status.Running : Status.Complete; }
public AnalogEvent(Xim.Analog button, int deadzone, Joystick.AnalogFlags flags) { this.analog = flags; this.button = button; this.deadzone = deadzone; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { Xim.ToggleButtonState(m_button, ref startState); Xim.ToggleButtonState(m_button, ref input); return Status.Complete; }
public HoldAnalogEvent(Xim.Analog button, short analogVal) { m_button = button; this.analogVal = analogVal; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { if( !firstRun ) m_elapsed+=elapsed; return m_elapsed > m_waitTime ? InputEvent.Status.Complete : InputEvent.Status.Blocking; }
public override InputEvent.Status Run(bool firstRun, double elapsed, bool keyStillPressed, ref Xim.Input input, ref Xim.Input startState) { if (keyStillPressed) { Xim.AddAnalogValue(m_button, this.analogVal, ref input); } return keyStillPressed ? Status.Running : Status.Complete; }