My First Question (Direct Input)?

Started by
1 comment, last by dark_exodus 20 years, 4 months ago
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
Advertisement
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]
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.
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno

This topic is closed to new replies.

Advertisement