Search code examples
visual-c++mfcjoystickdirectinput

programming joystick in DirectInput


I'm writing application to program Joystick using DirectInput and MFC. I have found a script how to do it, but i have a problem. When i want to enumerate devices to find joystick I use right function "EnumDevices" with argument "enumCallback" which is a function too. I now it's not a way the function should be called but normally it works. I don't now what is wrong. Thanks for help!

void Joystick::Załaduj_Pada()
{
    Czy_Jest_Pad = true;
    // Create a DirectInput device
     DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&di, NULL); 


     di->EnumDevices(DI8DEVCLASS_GAMECTRL,enumCallback,NULL,DIEDFL_ATTACHEDONLY);

    // Make sure we got a joystick
    if (joystick == NULL) 
    {Czy_Jest_Pad=false;}

}

error C3867: 'Joystick::enumCallback': function call missing argument list; use '&Joystick::enumCallback' to create a pointer to member


Solution

  • try

    di->EnumDevices(DI8DEVCLASS_GAMECTRL,&enumCallback,NULL,DIEDFL_ATTACHEDONLY
    

    place '&' before enumCallback.