Solved

Joystick Detection problem with Win API

Posted on 1997-06-13
1
549 Views
Last Modified: 2013-12-03
I have a SB16 with Joystick port in my pc, but no joystick attached to the port. My program checks for an attached joystick, otherwise it uses the mouse. To check if a joystick port exists, I use:

UINT NumDevices = joyGetNumDevs();

After this, NumDevices = 16. I have only one joystick port, should this not be 1?

Then I check to see which device is attached.
(Like shown in the win32 API Help file)

UINT Dev1Attached = joyGetPos(JOYSTICKID1,&joyinfo) != JOYERR_UNPLUGGED;
...

This gives no error, and the program thinks that 16 devices are avaiable and that device 1 is attached.
0
Comment
Question by:Claude050897
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1398241
The joyGetNumDevs function queries the joystick driver for the number of joysticks it supports. In your case, it returns 16 which means your joystick driver supports 16 joysticks (but, as Win32 documentation says, joystick drivers can support either one or two joysticks). The return value does not indicate the number of joystick ports.

To check if a joystick is attached to the system, you'd better use:

BOOL bDev1Attached = joyGetPos(JOYSTICKID1,&joyinfo) == JOYERR_NOERROR;

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

825 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