Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by CHollman82 Jun 3, 2007 at 5:27 PM 3 replies 1.1k views
Original Post
CHollman82
CHollman82
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();
ET3D
ET3D
What error does it return?

Do you have a valid hwnd?
CHollman82
CHollman82
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();
smitty1276
smitty1276
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.