public void FireEvent(VariableInputEvent e) { OnVariableInputEvent(e); }
private void QueryInputsAndFireEvents() { // Check Variable Inputs foreach (RegisteredVariableInput rvi in m_registeredVariableInput) { Vector2 value = Vector2.Zero; bool haveInput = false; switch (rvi.InputType) { case VariableInputType.Mouse: if ((MouseState.X != PrevMouseState.X) || (MouseState.Y != PrevMouseState.Y)) { value = new Vector2(MouseState.X, MouseState.Y); haveInput = true; } break; case VariableInputType.LeftThumbStick: if (GamePadState.ThumbSticks.Left != PrevGamePadState.ThumbSticks.Left) { value = GamePadState.ThumbSticks.Left; haveInput = true; } break; case VariableInputType.RightThumbStick: if (GamePadState.ThumbSticks.Right != PrevGamePadState.ThumbSticks.Right) { value = GamePadState.ThumbSticks.Right; haveInput = true; } break; case VariableInputType.LeftTrigger: if (GamePadState.Triggers.Left != PrevGamePadState.Triggers.Left) { value = new Vector2(GamePadState.Triggers.Left, 0); haveInput = true; } break; case VariableInputType.RightTrigger: if (GamePadState.Triggers.Right != PrevGamePadState.Triggers.Right) { value = new Vector2(GamePadState.Triggers.Right, 0); haveInput = true; } break; default: // TODO: error! break; }; if (haveInput == true) { VariableInputEvent e = new VariableInputEvent(InputEventType.ChangedValue, rvi.InputType, value); rvi.FireEvent(e); } } // Check Buttons foreach (RegisteredGamePadButton rb in m_registeredButtons) { if (PrevGamePadState.IsButtonDown(rb.Button) != GamePadState.IsButtonDown(rb.Button)) { GamePadButtonEvent e; if (GamePadState.IsButtonDown(rb.Button)) { e = new GamePadButtonEvent(InputEventType.Pressed, rb.Button); } else { e = new GamePadButtonEvent(InputEventType.Released, rb.Button); } rb.FireEvent(e); } } // Check Keys foreach (RegisteredKey rkey in m_registeredKeys) { if (PrevKeyboardState.IsKeyDown(rkey.Key) != KeyboardState.IsKeyDown(rkey.Key)) { KeyboardEvent e; if (KeyboardState.IsKeyDown(rkey.Key)) { e = new KeyboardEvent(InputEventType.Pressed, rkey.Key); } else { e = new KeyboardEvent(InputEventType.Released, rkey.Key); } rkey.FireEvent(e); } } }