Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

How to check if a joystick is connected without using the EnumJoysticksCallback func?

This topic is 4855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, im using c++, and I'm trying to check if a single joystick has been connected to the computer, so I can then create a device for it. My problem is when looking at the dx sdk tutorials, it says I have to use:
Quote:
g_pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY)
My problem is that it wants me to define/use the function:
Quote:
BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext) { HRESULT hr; // Obtain an interface to the enumerated joystick. hr = g_pDI->CreateDevice(pdidInstance->guidInstance, &g_pJoystick, NULL); if(FAILED(hr)) return DIENUM_CONTINUE; return DIENUM_STOP;
My problem is that I have an Input class that I am wrapping up all my input devices(keyboard,mouse,joystick) into. And I can't put the callback function into that class without making it a static function, as I can't access a member function. But then ofcourse the callback function doesn't have access to the IDirectInput8 class which is also declared in the Input class. So basically I need a way to check if there is a joystick attached to the computer without using that callback function. Any ideas? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!