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

x
?
Solved

Joystick Detection problem with Win API

Posted on 1997-06-13
1
Medium Priority
?
563 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 150 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 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