Sign in to follow this  

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

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this