/// <summary>
/// Get list of available joysticks connected to the system.
/// </summary>
///
/// <returns>Returns list containing information about available joysticks connected to
/// the system.</returns>
///
public static List <DeviceInfo> GetAvailableDevices()
{
List <DeviceInfo> devices = new List <DeviceInfo>();
int joyCapsSize = System.Runtime.InteropServices.Marshal.SizeOf(typeof(JoystickAPI.JOYCAPS));
// get number of devices
int devicesCount = JoystickAPI.joyGetNumDevs();
// check all devices
for (int i = 0; i < devicesCount; i++)
{
JoystickAPI.JOYCAPS joyCaps = new JoystickAPI.JOYCAPS();
if (JoystickAPI.joyGetDevCapsW(i, joyCaps, joyCapsSize) == JoystickAPI.ResultCode.NoError)
{
devices.Add(new DeviceInfo(i, joyCaps));
}
}
return(devices);
}