Windows and the 5-Button Wheel Mouse

Updated: December 4, 2001
*
On This Page
Windows and the 5-Button Wheel MouseWindows and the 5-Button Wheel Mouse
5-Button Activation (or "Knocking") Method5-Button Activation (or "Knocking") Method
Data Packet FormatData Packet Format
Mouse Driver and SDK AspectsMouse Driver and SDK Aspects

Windows and the 5-Button Wheel Mouse

Microsoft Windows 2000, Windows XP, and Windows Millennium Edition (Windows Me) provide support for PS/2-compatible and USB 5-button wheel mice, such as the Microsoft IntelliMouse Explorer. This support is in addition to built-in support for PS/2-compatible and USB standard 2-button mice and IntelliMouse-compatible 3-button wheel mice.

This article provides details on how Windows sets a PS/2-compatible mouse to 5-button mode, and what the input data packet format from the mouse should be when it is in this mode.

NOTE: This article applies only to PS/2-compatible mice. A USB 5-button wheel mouse should simply report two additional buttons--buttons 4 and 5--in its HID report descriptor to be fully supported by Windows.

Top of pageTop of page

5-Button Activation (or "Knocking") Method

The method used by Windows to activate the new 5-button wheel mode is an extension of the method used to activate the third button and the wheel in IntelliMouse-compatible mice:

First, the mouse is set to the 3-button wheel mode, which is accomplished by setting the report rate consecutively to 200 reports/second, then to 100 reports/second, then to 80 reports/second, and then reading the ID from the mouse. The mouse should report an ID of 3 when this sequence is completed.

Next, the mouse is set to the 5-button wheel mode, which is accomplished by setting the report rate consecutively to 200 reports/second, then to 200 reports/second again, then to 80 reports/second, and then reading the ID from the mouse. Once this sequence is completed, a 5-button wheel mouse should report an ID of 4 (whereas an IntelliMouse-compatible 3-button wheel mouse would still report an ID of 3).

Top of pageTop of page

Data Packet Format

For reference, the standard PS/2-compatible mouse data packet format is as shown in the following table.

Data Packet Format for PS/2-compatible Mouse

ByteD7D6D5D4D3D2D1D0Comment

1

Yover

Xover

Ysign

Xsign

Tag

M

R

L

X/Y overflows and signs, buttons

2

X7

X6

X5

X4

X3

X2

X1

X0

X data byte

3

Y7

Y6

Y5

Y4

Y3

Y2

Y1

Y0

Y data byte

Windows mouse drivers do not check the overflow bits. In case of overflow, the mouse should simply send the maximal signed displacement value.

Also for reference, the data packet format for an IntelliMouse-compatible 3-button wheel mouse is as shown in the following table.

Data Packet Format for 3-button Wheel Mouse

ByteD7D6D5D4D3D2D1D0Comment

1

0

0

Ysign

Xsign

1

M

R

L

X/Y signs and R/L/M buttons

2

X7

X6

X5

X4

X3

X2

X1

X0

X data byte

3

Y7

Y6

Y5

Y4

Y3

Y2

Y1

Y0

Y data byte

4

Z7

Z6

Z5

Z4

Z3

Z2

Z1

Z0

Z/wheel data byte

The new data packet format for a 5-button wheel mouse should be as shown in the following table.

Data Packet Format for 5-button Wheel Mouse

ByteD7D6D5D4D3D2D1D0Comment

1

0

0

Ysign

Xsign

1

M

R

L

X/Y signs and L/R/M buttons

2

X7

X6

X5

X4

X3

X2

X1

X0

X data byte

3

Y7

Y6

Y5

Y4

Y3

Y2

Y1

Y0

Y data byte

4

0

0

B5

B4

Z3

Z2

Z1

Z0

Z/wheel data and buttons 4 and 5

Notice that the Z/wheel data for a 5-button wheel mouse has been reduced to four bits instead of the 8 bits used in the IntelliMouse-compatible 3-button wheel mode. This reduction is made possible by the fact that the wheel typically cannot generate values beyond the range +7/-8 during any given interrupt period. Windows mouse drivers will sign extend the four Z/wheel data bits when the mouse is in the 5-button wheel mode, and the full Z/wheel data byte when the mouse operates in the 3-button wheel mode.

Top of pageTop of page

Mouse Driver and SDK Aspects

The PS/2-compatible and USB mouse drivers and the User32 component in Windows supports the two extra buttons and the new, shorter Z/wheel data format reported by a 5-button wheel mouse. The first three bits of byte 1 in the input data packet are always mapped to the Left, Right, and Middle buttons, respectively, as specified earlier.

However, buttons 4 and 5 are not mapped to any specific User32 or Shell functionality; instead these buttons can be mapped by software applications to application-specific functionality. More specifically, these buttons are mapped to new WM_APPCOMMAND messages that are in Windows to notify software applications of application command events. For additional information about application development, see the Microsoft Platform SDK.

Some Microsoft applications provided with Windows will implement default mappings of buttons 4 and 5 to specific functionality. For example, the built-in Internet Explorer web browser will map buttons 4 and 5 to "Back" and "Forward" web page navigation, respectively.

Vendors who are producing or are planning to produce 5-button wheel mice that are not compatible with the activation method or the new input data packet format as specified earlier can still take advantage of the support provided by Windows and their built-in applications.

Windows 2000/Windows XP.

To take advantage of the support provided by Windows 2000/Windows XP, an IHV-specific filter driver is required. This filter driver should be inserted in between the port driver, I8042prt.sys, and the Mouse class driver, Mouclass.sys. This filter driver should implement the following functionality:

Initialize the mouse and set it to its 5-button wheel mode in a vendor-specific way.
This can be done by hooking the ISR routine in the filter driver. When the ISR hook is called, and when MouseState equals MouseResetting and ResetSubState equals Enable5Buttons, the filter driver should write any vendor-specific initialization commands to the mouse and return true each time so that the I8042prt.sys driver stops processing the data. The Pnpi8042 sample driver in the Windows DDK shows how I8042prt.sys driver handles an ISR hook.

Re-map the IHV-specific input data packet into the new format specified above before the data is passed on to the Mouclass.sys driver.

Windows Me.

To take advantage of the support provided by Windows Me, a vendor-specific mini-driver to Vmouse.vxd is required. This mini-driver should implement the following functionality:

Initialize the mouse and set it to its 5-button wheel mode in a vendor-specific way.

Re-map the vendor-specific input data packet into the new format specified before the data is passed on to Vmouse.vxd.

Call to action for wheel mouse in Windows:

If you are developing mouse drivers for Windows 2000/Windows XP, see the Windows DDK for information about how to develop filter drivers. Sample filter drivers and documentation can be found in the %ntddk%\src\input\moufiltr directory.
For information about the INF mechanisms for installing such a filter driver, see Input Device Drivers and Windows.

If you are developing a mouse that has a vendor-specific activation method for Windows Me, see the topic on Mouse Minidriver Services in the Windows 98 DDK.


Top of pageTop of page