Tutorial 2: Using the Mouse

This tutorial guides you through the process of setting up a mouse device and retrieving buffered input data. The examples are taken from the Scrawl sample application included in the Sdk\Samples directory of the DirectX code samples in the Platform SDK References.

To prepare for mouse input, you first create an instance of a DirectInput object. Then you use the IDirectInput::CreateDevice method to create an instance of an IDirectInputDevice interface. The IDirectInputDevice interface methods are used to manipulate the device, set its behavior, and retrieve data.

The preliminary step of setting up the DirectInput system and the final step of closing it down are the same for any application and are covered in Tutorial 1: Using the Keyboard.

This tutorial breaks down the required tasks into the following steps:

Note  When an application acquires the mouse at the exclusive cooperative level, Windows does not show a mouse pointer on the screen. For this, your application needs a simple sprite engine. The Scrawl sample application uses the Win32 function DrawIcon to display a crosshair cursor.