Facepunch / sbox-issues

175 stars 12 forks source link

`Input.Down` keys down get overridden by controller up #4762

Closed timmybo5 closed 8 months ago

timmybo5 commented 9 months ago

Describe the bug

After 2 frames of holding down the button it returns false.

protected override void OnUpdate()
{
    Log.Info( "IsCrouching -> " + Input.Down( "Duck" ) );
}

image

fantasticaneer commented 9 months ago

I can't replicate this, if I put logic in a block like this:

protected override void OnUpdate() {
        if ( Input.Down( "Duck" ) )
        {
            Log.Info( "IsCrouching: " + Input.Down( "Duck" ) );
            AnimationHelper.DuckLevel = 1.00f;
            var crouchcc = GameObject.Components.Get<CharacterController>();
            crouchcc.Height = 45;
            CameraHeightPos = 35.0f;
        }

it works totally fine for me, including logging every frame I hold duck.

Maybe something is wonky in your code...?

protected override void OnUpdate()
{
    Log.Info( "IsCrouching -> " + Input.Down( "Duck" ) );
}

Just this works totally fine for me, too.

handsomematt commented 9 months ago

This doesn't sound right. Is there anything else you can add? Do you have a controller plugged in?

timmybo5 commented 9 months ago

I keep forgetting my controller is plugged in all the time, unplugging it fixed the issue! Thanks :D

handsomematt commented 9 months ago

Still a bug though

fantasticaneer commented 9 months ago

I think most games have a sort of switching system where the game switches between controller mode and mouse/keyboard mode depending upon whichever input was detected last so that inputs don't get contaminated between the two on accident like this. Also so that input UI elements can switch over depending on which 'mode' you're in.

Something like that would be good. I guess there's some wacky situation where you might want to play a game that uses both controller AND keyboard or something like that so it should be overridable maybe, but that sounds like a pretty rare case.

DevulTj commented 9 months ago

Huh, this is a fun one. Looks like it'd be related to my changes the other day.

yuberee commented 9 months ago

image EDIT: Oh whoops looks like it was already mentioned

DevulTj commented 8 months ago

This should be working as intended now