Compartir a través de


joySetCapture function

The joySetCapture function captures a joystick by causing its messages to be sent to the specified window.

Syntax

MMRESULT joySetCapture(
   HWND hwnd,
   UINT uJoyID,
   UINT uPeriod,
   BOOL fChanged
);

Parameters

  • hwnd
    Handle to the window to receive the joystick messages.

  • uJoyID
    Identifier of the joystick to be captured. Valid values for uJoyID range from zero (JOYSTICKID1) to 15.

  • uPeriod
    Polling frequency, in milliseconds.

  • 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.

Return value

Returns JOYERR_NOERROR if successful or one of the following error values.

Return code Description
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.

 

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.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Mmsystem.h (include Windows.h)

Library

Winmm.lib

DLL

Winmm.dll

See also

Joysticks

Multimedia Joystick Functions