Solved

Joystick Detection problem with Win API

Posted on 1997-06-13
1
547 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now