   DirectInput 8 callbacks - no thanks
  Hi I want to create a class for input devices. The VC++ sampleshows how to enumerate all joysticks but i only ever want the first one and i cant overide the method or implement them in a class. Also i cant determine the size value to get any type of access with enumerating.// Look for a simple joystick we can use for this sample program.if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback,NULL, DIEDFL_ATTACHEDONLY ) ) )return hr;//callsif( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, (VOID*)hDlg, DIDFT_ALL ) ) )return hr;//callsBOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext )// pdidoi IT''''s Geeky    IT''''s Geeky 
  Make the callback a static member function of your class, then when you call DInput to perform the enumeration, pass in a pointer to your class in the pContext argument.If none of that makes sense, it probably means I misunderstood your question. ;  Yes that works fine. I wasn''t sure what pContext was doing. So now i pass a class pointer initialised to ''this object'' and wahoo no more enumeration!  ;  //-----------------------------------------------------------------------------// Name: EnumJoysticksCallback()// Desc: Called once for each enumerated joystick. If we find one, create a//  device interface on it so we can play with it.//-----------------------------------------------------------------------------class{...CInputDevice *p_In; // Create this type of object in DirectInput enumeration}CInputDevice::CInputDevice(){m_pDI    = NULL;    m_pJoystick   = NULL;m_X = m_Y = 0;p_In = this;}BOOL CALLBACK CInputDevice::EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance,VOID * m_pDI)// p_In{CInputDevice *p_Dev;HRESULT hr;p_Dev = (CInputDevice*)m_pDI;    // Obtain an interface to the enumerated joystick.    hr =  p_Dev->m_pDI->CreateDevice( pdidInstance->guidInstance, &p_Dev->m_pJoystick, NULL );    // If it failed, then we can''t use this joystick. (Maybe the user unplugged    // it while we were in the middle of enumerating it.)    if( FAILED(hr) )    return DIENUM_CONTINUE;    // Stop enumeration. Note: we''re just taking the first joystick we get. You    // could store all the enumerated joysticks and let the user pick.    return DIENUM_STOP;} 