Accord.Controls.JoystickAPI.joyGetPosEx C# (CSharp) Method

joyGetPosEx() private method

private joyGetPosEx ( int uJoyID, JOYINFOEX pji ) : ResultCode
uJoyID int
pji JOYINFOEX
return ResultCode
        public static extern ResultCode joyGetPosEx(int uJoyID, JOYINFOEX pji);

Usage Example

Beispiel #1
0
        /// <summary>
        /// Get joystick's status.
        /// </summary>
        ///
        /// <returns>Returns current status of initialized joystick, which provides information
        /// about current state of all axes, buttons and point of view.</returns>
        ///
        /// <remarks><para><note>Before using this method the joystick object needs to be initialized
        /// using <see cref="Init"/> method or <see cref="Joystick(int)"/> constructor.</note></para></remarks>
        ///
        /// <exception cref="NotConnectedException">The requested joystick is not connected to the system.</exception>
        /// <exception cref="ApplicationException">Joystick was not initialized.</exception>
        ///
        public Status GetCurrentStatus()
        {
            JoystickAPI.JOYINFOEX ji = new JoystickAPI.JOYINFOEX();

            ji.size  = System.Runtime.InteropServices.Marshal.SizeOf(ji);
            ji.flags = (Info.capabilities.axesNumber > 5) ? JoystickAPI.JoyPosFlags.ReturnAll :
                       requestFlags[Info.capabilities.axesNumber];

            if (JoystickAPI.joyGetPosEx(Info.ID, ji) != JoystickAPI.ResultCode.NoError)
            {
                throw new NotConnectedException("The requested joystick is not connected to the system.");
            }

            return(new Status(ji, Info.capabilities));
        }