Microsoft DirectX 9.0

Mouse Sample


The Mouse sample program enables the exploration of Foreground versus Background and Exclusive versus Non-Exclusive cooperative levels, and Buffered versus Immediate data retrieval from the mouse.


Source: (SDK root )\Samples\C++\DirectInput\Mouse

Executable: (SDK root )\Samples\C++\DirectInput\Bin\Mouse.exe

User's Guide

Through the user interface, any combination of cooperative level and data styles can be created and the resulting keyboard behavior observed. Each setting is explained as it is selected, and the expected behavior is predicted when the device is created.

To release the mouse, press ENTER.

Programming Notes

Note that in immediate mode, all device objects are visible and you can see the data change as the mouse is moved. This is an optical illusion because Microsoft?DirectInput?is taking individual snapshots at the rate of twelve times a second, but it demonstrates that, in immediate mode, only the state of the device at that time is considered, while anything that has happened between device snapshots is ignored.

Holding down a button in buffered mode briefly displays the data indicating that the button has been pressed, then quickly clears that data as it is flushed from the buffer. Releasing the button generates another briefly displayed button up event. This is a significant difference from immediate mode.

© 2002 Microsoft Corporation. All rights reserved.