GetDeviceState problem
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 :)
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement