Archived

This topic is now archived and is closed to further replies.

nightsonic

Direct Input 8 woes....

Recommended Posts

nightsonic    122
I am trying to write some DirectX Wrappers and I am having trouble..... I am still new to the whole programming thing so any help would be apreciated... here is my problem.... I have a class called WinterDreamsInput In WinterDreamsInput I have a function that looks like this // This is what I will use to init the joystick bool WinterDreamsInput::DirectInputInitJoystick(HWND Main_Window_Handle); and a function that looks like this // This is a function the Direct input docs say you have to // have.... WinterDreamsInput::BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext) bool WinterDreamsInput::DirectInputInitJoystick(HWND Main_Window_Handle) { //First step enum devices if(dinputobject->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY) != DI_OK) return false; return true; } Ok here is my problem.... I already set the Callback function up but when I compile i get this error.... c:\test\winterdreamsinput.cpp(66) : error C2664: ''EnumDevices'' : cannot convert parameter 2 from ''int (const struct DIDEVICEINSTANCEA *,void *)'' to ''int (__stdcall *)(const struct DIDEVICEINSTANCEA *,void *)'' Can anyone help me out and tell me why I get this error? Thanks!

Share this post


Link to post
Share on other sites
Psybr    122
i dont really understand callback functions that well, but it seems as if your problem is having a function pointer as a member function, and you can search the forums for some threads on them

Share this post


Link to post
Share on other sites
IndirectX    122
You need to use __stdcall modifier. You can get it another way by using WINAPI, which is #defined to __stdcall:

bool __stdcall SomeFn(...);
bool WINAPI SomeFn(...);

I think the second way is the recommended one.

Share this post


Link to post
Share on other sites
VolkerG    151
Psybr should be right, you can''t pass a non static method to a callback that expects a non member function. Has been disussed sveral times.

Share this post


Link to post
Share on other sites