Exemple #1
0
        public void Update(Hid hleHid, TamperMachine tamperMachine)
        {
            lock (_lock)
            {
                List <GamepadInput> hleInputStates  = new List <GamepadInput>();
                List <SixAxisInput> hleMotionStates = new List <SixAxisInput>(NpadDevices.MaxControllers);

                KeyboardInput?hleKeyboardInput = null;

                foreach (InputConfig inputConfig in _inputConfig)
                {
                    GamepadInput inputState  = default;
                    SixAxisInput motionState = default;

                    NpadController controller = _controllers[(int)inputConfig.PlayerIndex];

                    // Do we allow input updates and is a controller connected?
                    if (!_blockInputUpdates && controller != null)
                    {
                        DriverConfigurationUpdate(ref controller, inputConfig);

                        controller.UpdateUserConfiguration(inputConfig);
                        controller.Update();

                        inputState = controller.GetHLEInputState();

                        inputState.Buttons |= hleHid.UpdateStickButtons(inputState.LStick, inputState.RStick);

                        motionState = controller.GetHLEMotionState();

                        if (ConfigurationState.Instance.Hid.EnableKeyboard)
                        {
                            hleKeyboardInput = controller.GetHLEKeyboardInput();
                        }
                    }
                    else
                    {
                        // Ensure that orientation isn't null
                        motionState.Orientation = new float[9];
                    }

                    inputState.PlayerId  = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex;
                    motionState.PlayerId = (Ryujinx.HLE.HOS.Services.Hid.PlayerIndex)inputConfig.PlayerIndex;

                    hleInputStates.Add(inputState);
                    hleMotionStates.Add(motionState);
                }

                hleHid.Npads.Update(hleInputStates);
                hleHid.Npads.UpdateSixAxis(hleMotionStates);

                if (hleKeyboardInput.HasValue)
                {
                    hleHid.Keyboard.Update(hleKeyboardInput.Value);
                }

                tamperMachine.UpdateInput(hleInputStates);
            }
        }