Sign in to follow this  

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

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:
My problem is that it wants me to define/use the function:
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this