Beispiel #1
0
        private unsafe int HandleInputsImpl()
        {
            if (Window.IsAnyWindowActivated())
            {
                _frameCounter += 1;
                for (int x = 0; x < Player.MaxNumberOfPlayers; x++)
                {
                    // Get inputs from player and convert to our format.
                    IPlayerInput inputs = new PlayerInput();

                    // Send inputs to other mods.
                    SetInputs?.Invoke(ref inputs, x);

                    // Post process inputs.
                    PostProcessInputs?.Invoke(ref inputs, x);

                    // Send copy of inputs to subscribers.
                    OnInput?.Invoke(inputs, x);

                    // Convert back to original struct and figure out some remaining members.
                    var playerInputs  = (PlayerInput)inputs;
                    var libraryInputs = playerInputs.ToLibrary();

                    // Add newly pressed and released buttons.
                    libraryInputs.Finalize(ref _lastFrameInputs[x], _frameCounter);

                    // Write inputs back to player.
                    _lastFrameInputs[x] = libraryInputs;
                    Player.Inputs[x]    = libraryInputs;
                }

                // Handle menu.
                var playerOneInputs    = Player.Inputs[0];
                *Player.MenuInputPress = playerOneInputs.ButtonsPressed;
                *Player.MenuInputHold  = playerOneInputs.Flicker;

                if (_frameCounter >= Sewer56.SonicRiders.Structures.Input.PlayerInput.TickPeriodFrames)
                {
                    _frameCounter = 0;
                }
            }

            return(0);
        }
 public void InvokePostProcessInputs(ref IInputs inputs, int port) => PostProcessInputs?.Invoke(ref inputs, port);