O'Reilly logo

DirectX 11.1 Game Programming by Pooya Eimandar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The input devices we'll need

In this section, we are going to learn how to handle input devices such as a keyboard, mouse or touch, and Xbox controllers. Let's start the integration of our framework with the keyboard, the old friend of gamers.

Keyboard

Open the Inputs project from the source code and then open the KeyboardState.cpp class from the FrameWork/Input folder. The KeyboardState.cpp class has the following code:

bool KeyboardState::IsKeyDown(VirtualKey key) { return keys[key] == true; } bool KeyboardState::IsKeyUp(VirtualKey key) { return keys[key] == false; } void KeyboardState::SaveKeyState(VirtualKey key, bool IsPressed) { keys[key] = IsPressed; } void KeyboardState::ClearBuffer() { for (auto k : this->keys) { k.second = false; } } void ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required