SFML/SFML.Net

Joystick doesn't update on Release build configuration

andre-sampaio opened this issue · 1 comments

Joystick won't update if build configuration is set to Release.

Minimal code sample:

static class Program
    {
        static void Main(string[] args)
        {
            var window = new RenderWindow(new VideoMode(200, 200), "Joystick doesn't read :(");
            Joystick.Update();

            uint connectedJoystick = 0;
            for (uint i = 0; i < Joystick.Count; i++)
            {
                var isConnected = Joystick.IsConnected(i);
                if (isConnected)
                    connectedJoystick = i;
            }

            while (window.IsOpen)
            {
                window.DispatchEvents();

                Console.SetCursorPosition(0, 0);
                Joystick.Update();

                for (uint i = 0; i < Joystick.AxisCount; i++)
                {
                    var position = Joystick.GetAxisPosition(connectedJoystick, (Joystick.Axis)i);
                    Console.WriteLine($"Axis {(Joystick.Axis)i}: {position}");
                }
            }
        }
    }

If built using Debug configuration Joystick.GetAxisPosition will work fine, while on Release the values for each Axis will be stuck on the same value.

IDE: Visual Studio 2019
.Net SDK: .NET Core 3.1.301
Platform: x64/x86/AnyCpu
Configuration: Release
OS: Windows 10

I'm closing this issue since I can no longer reproduce it.

Not sure if this is a coincidence or not but this piece of code started to work after I built CSFML and C++ SFML myself.