Using the Keyboard Device

Each of the devices you can use in DirectInput have their own Device object, much like each graphics card and sound card have their own device objects. There are normally more DirectInput devices than the others though.

Creating a device requires a GUID to be passed in that is the same as the instance GUID you receive when enumerating your devices. It can also be a member of the SystemGuid object if you only want to create the default keyboard or mouse device. The devices that are created are generic enough to retrieve data from any device support by DirectInput.

Our first look at the device will start with the most common device, the keyboard. You will obviously need a device variable to use, so go ahead and declare ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.