Thursday, April 12, 2007

Keyboard of BuddhaInput

BuddhaInput makes it possible to get the current keyboard state as well by the same grammar as XNA. But, BuddhaInput needs the special initialize for DirectInput8 Initializing. The game class does it automatically.

KeyboardState state = Keyboard::GetState();
if (state.IsKeyDown(Keys::Left))
...

This code is the same as XNA's, but it needs the overload for copying 256 bytes. And so, you may use the following pattern.

KeyboardState state;
Keyboard::GetState(state);

IsKeyDown method & IsKeyUp method returns a bool value. For the parameter, you may Keys::xxx or DIK_XXX.

No comments: