• Advertisement
Sign in to follow this  

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

This topic is 4586 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