Program hangs/freezes when DirectInput GetDevices() is called C#

164 views Asked by At

Trying to get Joystick input with DirectX DirectInput but the program seems to hang/freeze without any errors on Manager.GetDevices().

Here is the simple code:

// C#
using Microsoft.DirectX.DirectInput;

namespace Input
{
    class Controller
    {

        static void InitJoystick()
        {
            foreach (DeviceInstance di in Manager.GetDevices( DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
            {
                Console.WriteLine(di.InstanceGuid);
            }
        }

        static void Main(string[] args)
        {
            InitJoystick();
        }
    }
}

Does anyone know what im doing wrong?

0

There are 0 answers