Solved

Joystick Detection problem with Win API

Posted on 1997-06-13
1
540 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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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