Microsoft DirectX 8.1 (C++)

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 based on the Scrawl Sample.

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

The first 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 divides the required tasks into the following steps.

Note  When an application acquires the mouse at the exclusive cooperative level, Microsoft 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 Microsoft Win32® function DrawIcon to display a crosshair cursor.