Microsoft KB Archive/199528

= BUG: CEPC Mouse Driver Moves Cursor Erratically =

Article ID: 199528

Article Last Modified on 10/24/2003

-

APPLIES TO


 * Microsoft Windows CE 2.10 Enhancement Pack for Windows CE Embedded Toolkit for Visual C++ 5.0
 * Microsoft Windows CE Platform Builder 2.11
 * Microsoft Windows CE Platform Builder 2.12

-



This article was previously published under Q199528



SYMPTOMS
The mouse cursor on the PC-based reference platform (CEPC) may move erratically on some hardware combinations or if the mouse is moved while the system is starting (on any hardware platform).



CAUSE
Mouse movement data arrives in fixed-length packets from the mouse hardware. If the alignment of the packets in the data stream becomes out of sync with the alignment the driver is expecting, the driver will misinterpret the mouse data. For example, movement information will be interpreted as button status, and button status will be interpreted as movement data.

The KBDMOUSE driver in Windows CE 2.11 for the x86 CEPC platform does contain code to resynchronize the mouse packets. However, due to a code defect, this part of the mouse driver does not function as intended.



RESOLUTION
The following modification to the KBDMOUSE sample driver will correct the problem.

In Ps2mouse.cpp, modify the function Ps2Mouse::IsrThreadProc as follows:  Remove, in its entirety, the first if/else clause that follows the wait_for_interrupt label.

  Modify the next if statement to read as follows:

if ( WaitForSingleObject(m_hevInterrupt, (cBytes == 0) ? INFINITE : INPACKET_TIMEOUT) == WAIT_TIMEOUT ) {           cBytes = 0; goto wait_for_interrupt; }                        Remove references to variables bInPacket and cmsInPacketTimeout.  Modify Ps2mouse.hpp to include: 
 * 1) define INPACKET_TIMEOUT 50



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. The correction to this problem is given in the RESOLUTION section of this article.



MORE INFORMATION
Mouse data arrives from the device in 3-byte packets. Each packet contains x and y movement data and a button-status byte. The mouse driver must synchronize the data at mouse reset and then keep a count of 3-byte packets.

The synchronization problem in the CEPC KBDMOUSE sample driver occurs when the mouse port has data in the input buffer after the mouse is initialized. This data is interpreted as the first byte of a mouse data packet, and so the first 2 bytes of the next mouse packet are interpreted as the second and third bytes of a packet. All subsequent packets are misinterpreted in the same way.

Additional query words: kbDSupport

Keywords: kbbug kbfix KB199528

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.