private static Joystick LoadJoystick(int index) { Joystick stick = new Joystick(); stick.ID = index; stick.Capabilities = new WinMMAPI.JOYCAPS(); int size = Marshal.SizeOf(stick.Capabilities); WinMMAPI.ResultCode result = WinMMAPI.joyGetDevCapsA(index, stick.Capabilities, size); if (result != WinMMAPI.ResultCode.NoError || stick.Capabilities.Name == string.Empty) { return(null); } for (int a = 0; a < stick.Capabilities.axesNumber; a++) { stick.Axes.Add(GetAxisLabel(a)); } for (int b = 0; b < stick.Capabilities.buttonsNumber; b++) { stick.Buttons.Add(GetButtonLabel(b)); } return(stick); }
public List <bool> GetButtonStates() { WinMMAPI.JOYINFOEX info = new WinMMAPI.JOYINFOEX(); info.flags = WinMMAPI.JoyPosFlags.ReturnAll; WinMMAPI.joyGetPosEx(ID, info); return(UpdateButtonState(info)); }
public List <double> GetAxisStates() { WinMMAPI.JOYINFOEX info = new WinMMAPI.JOYINFOEX(); info.flags = WinMMAPI.JoyPosFlags.ReturnAll; WinMMAPI.joyGetPosEx(ID, info); return(UpdateAxisState(info)); }
public void StartCapture() { WinMMAPI.JOYINFOEX info = new WinMMAPI.JOYINFOEX(); info.flags = WinMMAPI.JoyPosFlags.ReturnAll; WinMMAPI.joyGetPosEx(ID, info); LastAxisPositions = UpdateAxisState(info); LastButtonStates = UpdateButtonState(info); }
public static Joystick[] GetDevices() { if (Devices.Count == 0) { for (int i = 0; i < WinMMAPI.joyGetNumDevs(); i++) { Joystick stick = LoadJoystick(i); if (stick != null) { Devices.Add(stick); } } } return(Devices.ToArray()); }