Esempio n. 1
0
            public void ItShouldRaiseAnEvent()
            {
                InputReceivedEventArgs actualArgs = null;
                var expectedArgs = new InputReceivedEventArgs("testInput");
                var resetEvent = new AutoResetEvent(false);
                Sut.InputReceived += (sender, args) =>
                    {
                        actualArgs = args;
                        resetEvent.Set();
                    };

                using (var reader = new StringReader("testInput"))
                {
                    Console.SetIn(reader);
                    Sut.ReadLine();
                }

                if (!resetEvent.WaitOne(100))
                    Assert.Fail("The input event was never raised.");
                actualArgs.ShouldBeEquivalentTo(expectedArgs);
            }
        bool ReportInputPredicate(InputReceivedEventArgs e)
        {
            if (e.Input.Dimensionality != Dimensionality) { return false; }

            switch (e.Input.Dimensionality)
            {
                case InputDimensionality.Digital:
                    return ((DigitalInputReceivedEventArgs)e).State;

                case InputDimensionality.Linear:
                case InputDimensionality.Planar:
                    return true;

                default:
                    return false;
            }
        }
Esempio n. 3
0
            protected override void Context()
            {
                base.Context();

                testInput = "input";
                testEventArgs = new InputReceivedEventArgs(testInput);

                const string sampleSum = "42";
                A.CallTo(() => Calculator.GetSum(A<string>._))
                 .Returns(sampleSum);
            }
Esempio n. 4
0
            protected override void Context()
            {
                base.Context();

                testInput = "input";
                testEventArgs = new InputReceivedEventArgs(testInput);

                A.CallTo(() => Calculator.GetSum(A<string>._))
                 .Throws(new InvalidInputException());
            }
Esempio n. 5
0
 protected void OnInputReceived(InputReceivedEventArgs e)
 {
     if (InputReceived != null) { InputReceived(this, e); }
 }
Esempio n. 6
0
 public virtual void OnInputReceived(object sender, InputReceivedEventArgs args)
 {
 }
Esempio n. 7
0
 static void gameContext_InputReceived(object sender, InputReceivedEventArgs e)
 {
     Console.WriteLine($"Input reveived: {e.Player}, {e.InputKey}");
     gameContext.CurrentState.UserInput(e.Player, e.InputKey);
 }
Esempio n. 8
0
        void InputAggregator_InputReceived(object sender, InputReceivedEventArgs e)
        {
            var de = e as DigitalInputReceivedEventArgs;
            if (de == null || de.Input.ID.DeviceName != "Keyboard0") { return; }

            InputSection inputConfig = _config.Input;

            if (de.State)
            {
                if (inputConfig.Joypad1.Up.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Up; }
                if (inputConfig.Joypad1.Down.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Down; }
                if (inputConfig.Joypad1.Left.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Left; }
                if (inputConfig.Joypad1.Right.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Right; }
                if (inputConfig.Joypad1.B.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.B; }
                if (inputConfig.Joypad1.A.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.A; }
                if (inputConfig.Joypad1.Y.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Y; }
                if (inputConfig.Joypad1.X.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.X; }
                if (inputConfig.Joypad1.L.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.L; }
                if (inputConfig.Joypad1.R.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.R; }
                if (inputConfig.Joypad1.Start.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Start; }
                if (inputConfig.Joypad1.Select.HasBindingTo(de.Input.ID)) { _buttonStates |= SnesJoypadButtons.Select; }

                _snes.SetInputState(1, 0, (int)_buttonStates, 0, 0);
            }
            else
            {
                if (inputConfig.Joypad1.Up.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Up; }
                if (inputConfig.Joypad1.Down.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Down; }
                if (inputConfig.Joypad1.Left.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Left; }
                if (inputConfig.Joypad1.Right.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Right; }
                if (inputConfig.Joypad1.B.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.B; }
                if (inputConfig.Joypad1.A.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.A; }
                if (inputConfig.Joypad1.Y.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Y; }
                if (inputConfig.Joypad1.X.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.X; }
                if (inputConfig.Joypad1.L.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.L; }
                if (inputConfig.Joypad1.R.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.R; }
                if (inputConfig.Joypad1.Start.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Start; }
                if (inputConfig.Joypad1.Select.HasBindingTo(de.Input.ID)) { _buttonStates &= ~SnesJoypadButtons.Select; }

                _snes.SetInputState(1, 0, (int)_buttonStates, 0, 0);
            }
        }
Esempio n. 9
0
 void InputHandler(object sender, InputReceivedEventArgs e)
 {
     OnInputReceived(e);
 }