UltravioletFramework / ultraviolet

The Ultraviolet Framework is a .NET game development framework written in C#.
https://github.com/UltravioletFramework/ultraviolet/wiki
MIT License
542 stars 46 forks source link

SDL IsButtonDown is never true for buttons representing sticks. #132

Closed fireball87 closed 4 years ago

fireball87 commented 4 years ago

I am currently implementing customizable controls, where I have an options screen that has events registered and allows you to press the button you want to use in game (which currently polls for inputs), I have found that the event Ultraviolet.GetInput().GetGamePadForPlayer(i).ButtonPressed fires when you hit stick inputs, but Ultraviolet.GetInput().GetGamePadForPlayer(gamePadDevice.PlayerIndex).IsButtonDown(button); will never return true for the buttons representing any axis. Nor does IsButtonPressed ever seem to.

So for the following event handler

        private void PadButtonPressed(GamePadDevice gamePadDevice, GamePadButton button, bool repeat)
        {
            bool isButtonDown = owner.Ultraviolet.GetInput().GetGamePadForPlayer(gamePadDevice.PlayerIndex)
                .IsButtonDown(button);
        }

isButtonDown will be always true if a digital input, like the dpad or axby, and false for any analog inputs, like triggers or analog sticks. As there is a point to represent these as possible buttons in the enum, I assume that the intent would be that isButtonDown/isButtonPressed would work to treat analog inputs as buttons as well.

tlgkccampbell commented 4 years ago

This should be addressed by commit 391627ea855835d7182c3d1a70142bc2f0b1a3e3, which will be part of the next release.