Accord.Controls.Joystick.Init C# (CSharp) Method

Init() public method

Initialize joystick with the specified ID.

Invalid joystick ID was specified. It must be in [0, 15] range. The requested joystick is not connected to the system.
public Init ( int id ) : void
id int Joystick's ID to initialize, [0, 15].
return void
        public void Init(int id)
        {
            if ((id < 0) || (id > 15))
            {
                throw new ArgumentException("Invalid joystick ID was specified.");
            }

            JoystickAPI.JOYCAPS joyCaps = new JoystickAPI.JOYCAPS();

            if (JoystickAPI.joyGetDevCapsW(id, joyCaps,
                System.Runtime.InteropServices.Marshal.SizeOf(joyCaps)) != JoystickAPI.ResultCode.NoError)
            {
                throw new NotConnectedException("The requested joystick is not connected to the system.");
            }

            info = new DeviceInfo(id, joyCaps);
        }