Archived

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

My First Question (Direct Input)?

This topic is 5128 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''ve created a class to handle input within my game but it doesn''t seem to work. I get no errors or warnings but nothing happens. Any help guys? Here is a link to my code : http://www25.brinkster.com/agm1tsc/keyboard.cpp

Share this post


Link to post
Share on other sites
You're going to have to be a little more specific. What kind of output are you getting? Do you successfully Acquire the keyboard? What values are getting returned in your array of buttons?

Also, make sure that you're running the Debug Runtimes. You can do this by going to Control Panel->DirectX. Then click on the Direct3D tab. Make sure that the debug output slider is on maximum and put a bullet beside Debug Runtime. This will cause Visual Studio to output debug messages that will give you hints as to why a given D3D function isn't working right. Do the same for the DirectInput tab

neneboricua

[edited by - neneboricua19 on November 29, 2003 5:34:44 PM]

Share this post


Link to post
Share on other sites
Okay, I did notice something that may perhaps be your problem.

Add these 2 lines in your Keyboard header file.

#define KEYDOWN(name, key) (name[key] & 0x80)
char buffer[256];

Your setup is good, and well logged, so if there was a problem your messages would tell you.

Each time you check for input, you should try something like this


if(FAILED(Keyboard->GetDeviceState(sizeof(buffer),(LPVOID)&buffer)))
{
Keyboard->Acquire();
Keyboard->GetDeviceState(sizeof(buffer),(LPVOID)&buffer);
}



And finally to check for keys...


if(KEYDOWN(buffer,DIK_W))
{
// move forward
}


There is a listing of all the DI Key names somewhere in the docs.

Hope this little rant helped.

Share this post


Link to post
Share on other sites