Jump to content
  • Advertisement
Sign in to follow this  
aviosity

GetKeyState 0x80 offset?

This topic is 4758 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!