public static Collection <JoystickInfo> GetJoysticks() { Collection <JoystickInfo> ret = new Collection <JoystickInfo>(); int count = NativeMethods.JoyGetNumDevices(); int size = Marshal.SizeOf(typeof(JoyCapabilitiesInfo)); for (int i = 0; i < count; i++) { JoyCapabilitiesInfo joystick = new JoyCapabilitiesInfo(); JoyResult result = NativeMethods.JoyGetDevCapsW(i, ref joystick, size); if (result == JoyResult.OK) { ret.Add(new JoystickInfo(i, joystick)); } } return(ret); }
internal JoystickInfo(Int32 id, JoyCapabilitiesInfo capabilities) { Id = id; Capabilities = capabilities; }
public static extern JoyResult JoyGetDevCapsW(int joyId, ref JoyCapabilitiesInfo pjc, int size);