Sign in to follow this  
aviosity

GetKeyState 0x80 offset?

Recommended Posts

Hey all, This is just for my general knowledge/enrichment, since Windows programming isn't really my gig (transferring over from Java here :-P). When using GetKeyState(VK_XXX), you always see it offset by 0x80 (using &). Now I've experimented with removing the offset, and in my application it quite obviously affects something (using it to control camera movement results in the camera just shooting through all geometry on its merry way to negative z oblivion). What does this 0x80 do? I've tried googling and searching the forums, but got nothing...sorry if I missed something, and thanks for any help. Aviosity

Share this post


Link to post
Share on other sites
GetKeyState doesn't only return whether or not the key is down. The high order of the return value says whether or not the key is down. Saying & 80 is a fancy and easier way of seeing which bits (the high bits) are set in the return value.

If you don't understand the AND (&) part, then it's very advisable to study up on your bitwise operations. They come in mighty useful. [smile]

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