Original Post
Hi, I'm trying to tidy up my dinput code by creating a nice input controller class. I have come unstuck with a bit of C++ syntax shenanigans and wondered if anyone could help me.
I am using the call below to enumerate joysticks. I'd like the EnumJoysticks function to be a function of the class instead of a standard C function. Is this possible?
hr = m_directInput->EnumDevices(DI8DEVCLASS_GAMECTRL,EnumJoysticks,this,DIEDFL_ATTACHEDONLY); //
[edited by - jpardon on February 28, 2004 9:56:28 AM]
this is a pointer to my currrent InputController class
The reason I'd like to do ths is so that I can store the enumerated data into the object directly without having to pass pointers to the function, and secondly because it'd be nice and tidy that way.
Here's the current EnumJoysticks function that I'm currently using...
BOOL CALLBACK EnumJoysticks(const DIDEVICEINSTANCE* pdidInstance,VOID* pContext)
{
HRESULT hr;
InputController *pIC = (InputController *)pContext;
// Get Joystick Device
//
hr = pIC->m_directInput->CreateDevice(pdidInstance->guidInstance,&pIC->m_joystickDevice,NULL);
if(hr != DI_OK) return DIENUM_CONTINUE;
// Return first Joystick Only
//
return DIENUM_STOP;
}
Thanks in advance for any suggestions