Sign in to follow this  
Netwatcher

Get previous key

Recommended Posts

Netwatcher    122
I'm using-> VC++ 2008 and DirectX 9 SDK <- I've been struggling with it for quiet a while now and i just can't figure out how to get the previous key stroke. here is what i want to do ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #game logic... (done) #check the previous key for some logic get key press (done) store new key press as previous key press ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ My main problem is that I cant figure out how to store the key press data... do u know a better way for getting previous key press? Please not the win32 keyboard method, only DX. (i wanna learn, not use old stuff, even if im not gonna use it as much) Thank you in advance, Netwatcher Edit: maybe what i'm looking for is how to store the DIK_//somekey value [Edited by - Netwatcher on May 2, 2009 3:13:13 PM]

Share this post


Link to post
Share on other sites
MJP    19754
I hate to break it to you, but by using DirectInput you ARE using old stuff. It's completely outdated for keyboard and mouse input, and there's absolutely no reason to use it for these things. In fact the only good reason left to use DI is for legacy gamepad/joystick support. If you really need low-level access to keyboard and mouse input then the Raw Input API's are easier to use and more efficient. If you just need more basic stuff or if you want proper keyboard/mouse pre-processing for GUI stuff, then Win32 messages are the way to go.

Anyway...you could just store your old key values in an array of bools, and use the keycode to index into the array.

Share this post


Link to post
Share on other sites
Netwatcher    122
Got it! dinput bad , win32 good :P and i meant new for me!(sry for the confusion)
I'm a newb... not hard to tell




Thanks guys!

I ended up using some bools as flags, and did use the DX thingy just cos it was easier and already set-up, that also means i need to make a new bool type for every key i want to do this for (in this case only one so it doesn't really matters)
Gonna note what you said for future projects though.
and... mhum... which method does XNA use? win32 or DX?



Cheers,
Netwatcher
~~~~~~~~~~~~~~~~~~~~~~~~~
I tried XNA and it's amazing (how easy everything is in C#...), the only problem is the high graphics req... damnit old laptop

still think i can do so much more in C/Cpp, maybe not now but you wait...

[Edited by - Netwatcher on May 3, 2009 11:55:14 PM]

Share this post


Link to post
Share on other sites

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