Direct Input 8

Overview

This article explains how to implement direct input. Direct Input is used to determine the keyboard, mouse, and joystick device states. Direct Input associates an id with the keyboard, mouse, and joystick device. Using the device id, properties are set to tell direct input how to return device status data. A timer event is call twelve time a second to display information queried from the device to the application. The device information is return in direct input data structures. The device status is either immediate or buffered. If the device is buffered the device property is changed to allow buffering.

Further in the article the different device modes are explained: immediate, buffered, background, foreground, and windowskeys.

The dinput.h has the scan code enumerated constants

So

hr = g_pKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), didod, &dwElements, 0 );

returns an array of 256 keyboard scan code states

Using the scan code constants

didod[ DIK_1 ].dwData & 0x80

returns either a 0 or 1

didod[ i ].dwOfs

returns the actual scan code

You might also like...

Comments

About the author

David Nishimoto United States

NishiSoft provides Part I of the Information Technology Project collaboration. Sign up and list your IT project tasks, assign task too friends, and get percent complete task.

Part will ...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann