Quote:Original post by n3Xus
thx for the help so far but I still can't figure it out...
this is a part of the .h file that defines the CALLBACK function:
*** Source Snippet Removed ***
this is a part of the .cpp file:
*** Source Snippet Removed ***
can someone tell me what exactly do I need to change to get this working??
You can't pass a non-static function to a callback like that, so you need to make the function static. A member function has an implicit "this" pointer, which means that it's not the same as a free-standing function, so you can't pass it in as a function pointer.
Doing that means that you can't access any member variables from within the function though, since it doesn't have a "this" pointer. That's what the context parameter is for.
You want the following...
Header:
static BOOL CALLBACK EnumJoysticksCallback(DIDEVICEINSTANCE *pdidInstance, void *pContext);
Source file:
// The callback functionBOOL DX_INPUT::EnumJoysticksCallback(DIDEVICEINSTANCE *pdidInstance, void *pContext){ DX_INPUT* pThis = (DX_INPUT*)pContext; // Obtain the interface to the enumerated joystick if(FAILED (pThis->m_lpDI->CreateDevice(pdidInstance->guidInstance, pThis->&m_pJoystick, NULL) )) { ONMESSAGE("cannont obtain joystick intefaces","error:dxinput"); return DIENUM_STOP; } return DIENUM_CONTINUE;}// In this function the EnumJoysticksCallback is passed as an paramter for m_lpDI->EnumDevices:void DX_INPUT::InitializeJoysticks(){ m_lpDI->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, this, DIEDFL_ATTACHEDONLY)}
That way, you pass in the "this" pointer as the context parameter to the callback function, then you grab it out and use it.