Jump to content
  • Advertisement
Sign in to follow this  
crystallight111

GetDeviceState problem

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

Hi, I have a struct like this: struct KeyboardState { uchar keys[256]; } then I want to update the keyboard state like this: KeyboardState* keyboard = new KeyboardState(); hr = di_keyboard->GetDeviceState(sizeof(keyboard->keys), (LPVOID)keyboard->keys); (LPVOID)keyboard->keys is the thing that doesn't work, how do I do it correctly? There's a reason that I put the keys buffer in it's own struct, I tried it with a simple uchar keys[256] as in the documentation just to make sure and it works with that. So I hope you can help me :)

Share this post


Link to post
Share on other sites
Advertisement
For one, you don't need the parentheses after KeyboardState in your call to operator new. Other than that, I'm not immediately seeing any problem. The (LPVOID) cast should, from my memory, apply to the ->keys variable, not the keyboard variable. First of all, make sure that your keyboard pointer is valid. Secondly, try putting parentheses around keyboard->keys, just to see what happens.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!