DirectInput: Code that works in VC++ version 6 does not work in version 8

Started by
3 comments, last by Namethatnobodyelsetook 16 years, 10 months ago
I have a super mario 3 clone I have been working on and in the process have upgraded from visual studio 6 to 2005 (version 8). The project will still build and run, but now keyboard input does not work at all, when it used to work fine. This is basically how I am handling input: //Variables LPDIRECTINPUT8 lpdi; LPDIRECTINPUTDEVICE8 keyboard; LPDIRECTINPUTDEVICE8 mouse; //Initialization DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&lpdi, NULL); //Keyboard lpdi->CreateDevice(GUID_SysKeyboard, &keyboard, NULL); keyboard->SetDataFormat(&c_dfDIKeyboard); keyboard->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND); keyboard->Acquire(); //Mouse lpdi->CreateDevice(GUID_SysMouse, &mouse, NULL); mouse->SetCooperativeLevel(hwnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND); mouse->SetDataFormat(&c_dfDIMouse); mouse->Acquire(); //Usage keyboard->GetDeviceState(sizeof(keys),&keys); mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate); If I throw in a quick check around keyboard->SetCooperativeLevel I find out that that function is returning an error... but I don't know why
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
Advertisement
What error does it return?

Do you have a valid hwnd?
Sorry it took so long to get back to you. I was wrong, all the intialization functions return properly, but when I call GetDeviceState() it returns DIERR_INVALIDPARAM. The only parameters sent to it are sizeof(keys) and &keys (keys is a 256 element array of unsigned int's).

Also remember that this did work fine before I upgraded, and I can upload the executable to prove it, or look at my site: codextreme.net

Another thing... This may sound stupid but I bought a new keyboard between the time that this was working and the time I came back to it and it was no longer working... I have a saitek eclipse now, in case there is some known problem with them...
codeXtremeif(you->intelligence < radish->intelligence) you->STFU();
If you are able to successfully link to the libraries and call the functions, then the problems should have nothing at all to do with the IDE. It's executing the same code.

Maybe you should check the paths that are set in the IDE and make sure you don't have some outdated libraries laying around somewhere, or some other environmental cause.
I believe it wants an array of chars, or BYTE.

This topic is closed to new replies.

Advertisement