🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectInput Key bindings

Started by
0 comments, last by Zenroth 24 years, 6 months ago
Just wondering what is the general method to remap keys to work with directinput.

I think it would be something like this no?
dword keys[array of all your key constants];
Then you can later do things like keys[up]=VK_UP;

Or am i way off track here?

Advertisement
You actually need a UCHAR keymap[256];
You then set the data format, acquire the keyboard, and then in your main loop get the keyboard key info with a call to IDIRECTINPUTDEVICE2::GetDeviceState();

Once you have that, you can use the keymap variable in an array, like this:

if(keyword[DIK_ESCAPE] & 0x80)
{
// escape is pressed, do something!
}

The DIK_* constants are DirectInput specific, they're not the win32 ones, and are probably explained in the SDK.

I hope this has helped. It is possible that some of the things I said don't make sense, I'm in the middle of my exams and haven't touched my compiler for 2 weeks or so.

------------------
/Alexander Deruwe

/Alexander Deruwe

This topic is closed to new replies.

Advertisement