Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to deal with extra Joystick buttons except 4 basic buttons?

Posted on 1998-04-27
3
Medium Priority
?
827 Views
Last Modified: 2013-11-19
Hi! I know both MM_JOY1BUTTONDOWN and MM_JOY1BUTTONUP windows messages are able to handle Joystick 4 basic buttons. Because my Joystick totally has 8 buttons. I do not know if I need to use MM_JOY1MOVE to handle the 4 extra Joystick buttons? Could I use MM_JOY1BUTTONDOWN AND MM_JOY1BUTTONUP to deal with that directly? If the answer is Yes, How? If using MM_JOY1MOVE is the only way to solve my problem, could you tell me how to do it? Please respond me ASAP.Thanks a lot!
0
Comment
Question by:jennyhou
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:jennyhou
ID: 1302673
Edited text of question
0
 

Accepted Solution

by:
santoroa earned 150 total points
ID: 1302674
In DirectInput lingo, the term "joystick" also encompasses game pads, flight yokes, pedal systems, and similar
devices. I'll use the term here with a similar range of meaning.

You can read the joystick either through Windows messages or by polling. In the first method, a window
"captures" the joystick with joySetCapture so that the window is notified whenever the joystick is moved or
a button is pressed. This makes it possible to turn the stick into a pointing device like the mouse: you can
move a pointer on the screen every time the angle of the stick is altered. Moby Dick, however, is concerned
with the position of the joystick on each pass through the game loop rather than with the stick's actual
movements, so you want to use joyGetPosEx to do your own polling rather than monitoring the message
queue.

Another reason not to use joySetCapture is that joystick messages are limited to three axes of movement
(e.g. left-right, forward-back, and throttle) and four buttons. This obviously won't do for a modern input
device like the Microsoft Sidewinder™ 3D Pro, which has eight buttons, a point-of-view hat, and four axes of
movement (including a throttle slider and a twisting motion on the stick itself). For the latest joysticks and
game pads you definitely need the power of joyGetPosEx, which returns the state of up to 32 buttons, six
axes, and the POV hat, besides transparently supporting both digital and analog devices.

The API reference advises using the old joyGetPos function for joystick devices that employ no more than
three axes and four buttons. It's true that joyGetPos is a bit simpler to implement, but joyGetPosEx works
with all joysticks, and I see no reason not to use it exclusively.

To include the extended joystick services in your program, you need to link to WINMM.LIB and include
MMSYSTEM.H.

Detecting the Joystick

To detect the primary joystick, simply call joyGetPosEx with the JOYSTICKID1 argument:


JOYINFOEX joyInfoEx;

ZeroMemory(joyInfoEx, sizeof(joyInfoEx);
joyInfoEx.dwSize = sizeof(joyInfoEx);
BOOL JoyPresent = (joyGetPosEx(JOYSTICKID1, &joyInfoEx) == JOYERR_NOERROR);

The function returns an error (non-zero) if the joystick is not properly installed in Windows or is simply
unplugged.

Note that, as with many of the other DirectX functions, you have to let joyGetPosEx know how big a
structure it has to fill--annoying, but necessary for forward compatibility. On the bright side, you don't have
to worry about the dwFlags field here, since you don't require any of the values returned in the structure.

0
 

Author Comment

by:jennyhou
ID: 1302675
Thanks a lot!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question