Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Runtime.InteropServices
- Imports HIDs.Joysticks
- ''' <summary>
- ''' Native API Functions for Joysticks
- ''' </summary>
- Partial Class NativeMethods 'joystick
- ''' <summary>
- ''' The joyConfigChanged function informs the joystick driver that the configuration has changed and should be reloaded from the registry.
- ''' </summary>
- ''' <param name="dwFlags">Reserved for future use. Must equal zero.</param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful. Returns JOYERR_PARMS if the parameter is non-zero.
- ''' </returns>
- ''' <remarks>
- ''' This function causes a window message to be sent to all top-level windows.
- ''' This message may be defined by applications that need to respond to changes in joystick
- ''' calibration by using RegisterWindowMessage with the following message ID:
- ''' #define JOY_CONFIGCHANGED_MSGSTRING "MSJSTICK_VJOYD_MSGSTR"
- ''' </remarks>
- ''' <see>
- ''' https://msdn.microsoft.com/en-us/library/windows/desktop/dd757104(v=vs.85).aspx
- '''</see>
- <DllImport("winmm.dll")>
- Public Shared Function joyConfigChanged(ByVal dwFlags As Integer) As MMResult
- End Function
- ''' <summary>
- ''' The joyGetDevCaps function queries a joystick to determine its capabilities.
- ''' </summary>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick to be queried. Valid values for uJoyID range from -1 to 15.
- ''' A value of -1 enables retrieval of the szRegKey member of the JoyCaps structure whether a device is present or not.
- ''' </param>
- ''' <param name="pjc">
- ''' Pointer to a JoyCaps structure to contain the capabilities of the joystick.
- ''' </param>
- ''' <param name="cbjc">
- ''' Size, in bytes, of the JoyCaps structure.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values:
- ''' MMSYSERR_NODRIVER: The joystick driver is not present, or the specified joystick identifier is invalid. The specified joystick identifier is invalid.
- ''' MMSYSERR_INVALPARAM: An invalid parameter was passed.
- ''' </returns>
- ''' <remarks>
- ''' Use the joyGetNumDevs function to determine the number of joystick devices supported by the driver.
- ''' This method fails when passed an invalid value for the cbjc parameter.
- ''' </remarks>
- ''' <see>
- ''' https://msdn.microsoft.com/en-us/library/windows/desktop/dd757105(v=vs.85).aspx
- ''' </see>
- <DllImport("winmm.dll")>
- Public Shared Function joyGetDevCaps(ByVal uJoyID As JoyId, ByRef pjc As JoyCaps, ByVal cbjc As Integer) As MMResult
- End Function
- ''' <summary>
- ''' The joyGetNumDevs function queries the joystick driver for the number of joysticks it supports.
- ''' </summary>
- ''' <returns>
- ''' The joyGetNumDevs function returns the number of joysticks supported by the current driver or zero if no driver is installed.
- ''' </returns>
- ''' <remarks>
- ''' Use the joyGetPos function to determine whether a given joystick is physically attached to the system.
- ''' If the specified joystick is not connected, joyGetPos returns a JOYERR_UNPLUGGED error value.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joyGetNumDevs() As Integer
- End Function
- ''' <summary>
- ''' The joyGetPos function queries a joystick for its position and button status.
- ''' </summary>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick to be queried. Valid values for uJoyID range from zero (JoyId.JOYSTICK1) to 15.
- ''' </param>
- ''' <param name="pji">
- ''' Pointer to a JoyInfo structure that contains the position and button status of the joystick.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values.
- ''' MMSYSERR_NODRIVER The joystick driver is not present.
- ''' MMSYSERR_INVALPARAM An invalid parameter was passed.
- ''' JOYERR_UNPLUGGED The specified joystick is not connected to the system.
- ''' </returns>
- ''' <remarks>
- ''' For devices that have four to six axes of movement, a point-of-view control, or more than four buttons, use the joyGetPosEx function.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joyGetPos(ByVal uJoyID As JoyId, ByRef pji As JoyInfo) As MMResult
- End Function
- ''' <summary>
- ''' The joyGetPosEx function queries a joystick for its position and button status.
- ''' </summary>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick to be queried. Valid values for uJoyID range from zero (JoyId.JOYSTICK1) to 15.
- ''' </param>
- ''' <param name="pji">
- ''' Pointer to a JoyInfoEx structure that contains extended position information and button status of the joystick.
- ''' You must set the Size and Flags members or joyGetPosEx will fail. The information returned from joyGetPosEx
- ''' depends on the flags you specify in Flags.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values.
- ''' MMSYSERR_NODRIVER The joystick driver is not present.
- ''' MMSYSERR_INVALPARAM An invalid parameter was passed.
- ''' MMSYSERR_BADDEVICEID The specified joystick identifier is invalid.
- ''' JOYERR_UNPLUGGED The specified joystick is not connected to the system.
- ''' JOYERR_PARMS The specified joystick identifier is invalid.
- ''' </returns>
- ''' <remarks>
- ''' This function provides access to extended devices such as rudder pedals, point-of-view hats,
- ''' devices with a large number of buttons, and coordinate systems using up to six axes.
- ''' For joystick devices that use three axes or fewer and have fewer than four buttons, use the joyGetPos function.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joyGetPosEx(ByVal uJoyID As JoyId, ByRef pji As JoyInfoEx) As MMResult
- End Function
- ''' <summary>
- ''' The joyGetThreshold function queries a joystick for its current movement threshold.
- ''' </summary>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick. Valid values for uJoyID range from zero (JoyId.JOYSTICK1) to 15.
- ''' </param>
- ''' <param name="puThreshold">
- ''' Pointer to a variable that contains the movement threshold value.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values.
- ''' MMSYSERR_NODRIVER The joystick driver is not present.
- ''' MMSYSERR_INVALPARAM An invalid parameter was passed.
- ''' </returns>
- ''' <remarks>
- ''' The movement threshold is the distance the joystick must be moved before a joystick position-change message
- ''' (JoyMessage.MM_JOY1MOVE, JoyMessage.MM_JOY1ZMOVE, JoyMessage.MM_JOY2MOVE, or JoyMessage.MM_JOY2ZMOVE)
- ''' is sent to a window that has captured the device. The threshold is initially zero.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joyGetThreshold(ByVal uJoyID As JoyId, ByRef puThreshold As UInteger) As MMResult
- End Function
- ''' <summary>
- ''' The joyReleaseCapture function releases the specified captured joystick.
- ''' </summary>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick. Valid values for uJoyID range from zero (JoyId.JOYSTICK1) to 15.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values.
- ''' MMSYSERR_NODRIVER The joystick driver is not present.
- ''' MMSYSERR_INVALIDPARAM The specified joystick device identifier uJoyID is invalid.
- ''' JOYERR_PARMS The specified joystick device identifier uJoyID is invalid.
- ''' </returns>
- ''' <remarks>
- ''' This method returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR when passed a valid joystick identifier that has not been captured.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joyReleaseCapture(ByVal uJoyID As JoyId) As MMResult
- End Function
- ''' <summary>
- ''' The joySetCapture function captures a joystick by causing its messages to be sent to the specified window.
- ''' </summary>
- ''' <param name="hwnd">
- ''' Handle to the window to receive the joystick messages.
- ''' </param>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick. Valid values for uJoyID range from zero (JoyId.JOYSTICK1) to 15.
- ''' </param>
- ''' <param name="uPeriod">
- ''' Polling frequency, in milliseconds.
- ''' </param>
- ''' <param name="fChanged">
- ''' Change position flag. Specify TRUE for this parameter to send messages only when the position
- ''' changes by a value greater than the joystick movement threshold. Otherwise, messages are sent
- ''' at the polling frequency specified in uPeriod.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values.
- ''' MMSYSERR_NODRIVER The joystick driver is not present.
- ''' MMSYSERR_INVALPARAM Invalid joystick ID or hwnd is NULL.
- ''' JOYERR_NOCANDO Cannot capture joystick input because a required service (such as a Windows timer) is unavailable.
- ''' JOYERR_UNPLUGGED The specified joystick is not connected to the system.
- ''' JOYERR_PARMS Invalid joystick ID or hwnd is NULL.
- ''' </returns>
- ''' <remarks>
- ''' If the specified joystick is currently captured, the function returns undefined behavior.
- ''' Call the joyReleaseCapture function to release the captured joystick, or destroy the window
- ''' to release the joystick automatically.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joySetCapture(ByVal hwnd As IntPtr, ByVal uJoyID As JoyId, ByVal uPeriod As UInteger, ByVal fChanged As Boolean) As MMResult
- End Function
- ''' <summary>
- ''' The joySetThreshold function sets the movement threshold of a joystick.
- ''' </summary>
- ''' <param name="uJoyID">
- ''' Identifier of the joystick. Valid values for uJoyID range from zero (JoyId.JOYSTICK1) to 15.
- ''' </param>
- ''' <param name="puThreshold">
- ''' New movement threshold.
- ''' </param>
- ''' <returns>
- ''' Returns MMSYSERR_NOERROR_OR_JOYERR_NOERROR if successful or one of the following error values.
- ''' MMSYSERR_NODRIVER The joystick driver is not present.
- ''' JOYERR_PARMS The specified joystick device identifier uJoyID is invalid.
- ''' </returns>
- ''' <remarks>
- ''' The movement threshold is the distance the joystick must be moved before a joystick position-change message
- ''' (JoyMessage.MM_JOY1MOVE, JoyMessage.MM_JOY1ZMOVE, JoyMessage.MM_JOY2MOVE, or JoyMessage.MM_JOY2ZMOVE) is sent to a window that has captured the device.
- ''' The threshold is initially zero.
- ''' </remarks>
- <DllImport("winmm.dll")>
- Public Shared Function joySetThreshold(ByVal uJoyID As JoyId, ByVal puThreshold As UInteger) As MMResult
- End Function
- End Class 'NativeMethods joystick
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement