示例#1
0
        /// <summary>
        /// Returns whether or not the given <see cref="InputMapping"/> was just activated.
        /// </summary>
        /// <param name="name">The name of the input mapping, that was saved within the current <see cref="InputProfile"/>, that should be tested.</param>
        /// <returns>Whether or not the <see cref="InputMapping"/> was just pressed.</returns>
        public bool Pressed(string name)
        {
            VerifyUpdateIsCalled();

            if (Profile == null)
            {
                throw new RelatusException("The input profile has not been set.");
            }

            InputMapping inputMapping = Profile.GetMapping(name);

            if (PlayerIndex == PlayerIndex.One)
            {
                if (KeyboardExt.Pressed(inputMapping.Keys) || MouseExt.Pressed(inputMapping.MouseButtons))
                {
                    return(true);
                }
            }

            if (gamePad.IsConnected)
            {
                if (gamePad.Pressed(inputMapping.GamepadButtons))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Returns whether or not the given <see cref="InputMapping"/> was just activated.
        /// </summary>
        /// <param name="name">The name of the input mapping, that was saved within the current <see cref="InputProfile"/>, that should be tested.</param>
        /// <returns>Whether or not the <see cref="InputMapping"/> was just pressed.</returns>
        public bool Pressed(string name)
        {
            VerifyUpdateIsCalled();

            InputMapping inputMapping = inputProfile.GetMapping(name);

            if (PlayerIndex == PlayerIndex.One)
            {
                if (KeyboardExt.Pressed(inputMapping.Keys) || MouseExt.Pressed(inputMapping.MouseButtons))
                {
                    return(true);
                }
            }

            if (gamePad.IsConnected)
            {
                if (gamePad.Pressed(inputMapping.GamepadButtons))
                {
                    return(true);
                }
            }

            return(false);
        }