Sign in to follow this  
crystallight111

GetDeviceState problem

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
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

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