Processing Joystick Messages
The following joystick messages can be sent to a window function. Numerals 1 and 2 in these messages correspond to the joystick initiating the message. MM_JOY1 messages are sent to the window function if your application requests input from the first joystick, and MM_JOY2 messages are sent if your application requests input from the second joystick. All messages report nonexistent buttons as released.
MM_JOY1MOVE MM_JOY2MOVE |
Report a change in the x-axis and/or y-axis position of the joystick. The wParam parameter contains a com-bination of JOY_BUTTON bit flags specifying which buttons were pressed. |
|
The low-order word of lParam contains the x-position of the joystick, and the high-order word contains the y-position. |
MM_JOY1ZMOVE MM_JOY2ZMOVE |
Report a change in the z-axis position of a 3-axis joystick. The wParam parameter contains a com-bination of JOY_BUTTON bit flags specifying which buttons were pressed. |
|
The low-order word of lParam contains the x-position of the joystick, and the high-order word contains the y-position. |
MM_JOY1BUTTONUP MM_JOY2BUTTONUP MM_JOY1BUTTONDOWN MM_JOY2BUTTONDOWN |
Report that a joystick button has been pressed or released. The wParam parameter contains one JOY_BUTTONCHG bit flag specifying which button changed state and a combination of JOY_BUTTON bit flags specifying the current button states. |
|
The low-order word of lParam contains the x-position of the joystick, and the high-order word contains the y-position. |
Summary: Using the Button Flags
The joystick services use the following bit flags, passed in the wParam parameter of the window function, to report the state of the joystick buttons:
JOY_BUTTON1 |
Set when button 1 is pressed. |
JOY_BUTTON1CHG |
Set when button 1 has changed state. |
JOY_BUTTON2 |
Set when button 2 is pressed. |
JOY_BUTTON2CHG |
Set when button 2 has changed state. |
JOY_BUTTON3 |
Set when button 3 is pressed. |
JOY_BUTTON3CHG |
Set when button 3 has changed state. |
JOY_BUTTON4 |
Set when button 4 is pressed. |
JOY_BUTTON4CHG |
Set when button 4 has changed state. |
The MM_JOYMOVE messages use the JOY_BUTTON flags to report the state (pressed or released) of all buttons on the specified joystick.
The MM_JOYBUTTONUP and MM_JOYBUTTONDOWN messages use the JOY_BUTTON flags to report the state (pressed or released) of all buttons on the specified joystick. Also, they use JOY_BUTTONCHG flags to indicate which button changed state, thereby generating the message.
For example, if the user presses and holds buttons 1 and 2 and then moves the stick, a window function might receive the following messages:
MM_JOY1BUTTONDOWN |
JOY_BUTTON1 | JOY_BUTTON1CHG |
MM_JOY1BUTTONDOWN |
JOY_BUTTON1 | JOY_BUTTON2 | JOY_BUTTON2CHG |
MM_JOY1MOVE |
JOY_BUTTON1 | JOY_BUTTON2 |
A window function might receive the following messages when the user presses and releases button 3 without moving the stick:
MM_JOY1BUTTONDOWN |
JOY_BUTTON3 | JOY_BUTTON3CHG |
MM_JOY1BUTTONUP |
JOY_BUTTON3CHG |