Solved

Joystick Detection problem with Win API

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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