{"id":37833,"date":"2004-09-17T07:00:00","date_gmt":"2004-09-17T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/09\/17\/why-does-my-mousetouchpad-sometimes-go-berzerk\/"},"modified":"2004-09-17T07:00:00","modified_gmt":"2004-09-17T07:00:00","slug":"why-does-my-mousetouchpad-sometimes-go-berzerk","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20040917-00\/?p=37833","title":{"rendered":"Why does my mouse\/touchpad sometimes go berzerk?"},"content":{"rendered":"<p>Each time you move a PS\/2-style mouse, the mouse send three bytes to the computer. For the sake of illustration, let&#8217;s say the three bytes are x, y, and buttons.<\/p>\n<p> The operating system sees this byte stream and groups them into threes: <\/p>\n<p> <u>x y b<\/u> <u>x y b<\/u> <u>x y b<\/u> <u>x y b<\/u> <\/p>\n<p> Now suppose the cable is a bit jiggled loose and one of the &#8220;y&#8221;s gets lost.  The byte stream loses an entry, but the operating system doesn&#8217;t know this has happened and keeps grouping them in threes. <\/p>\n<p> <u>x y b<\/u> <u>x b x<\/u> <u>y b x<\/u> <u>y b x<\/u> <\/p>\n<p> The operating system is now out of sync with the mouse and starts misinterpreting all the data. It receives a &#8220;y b x&#8221; from the mouse and treats the y byte as the x-delta, the b byte as the y-delta, and the x byte as the button state. Result: A mouse that goes crazy. <\/p>\n<p> Oh wait, then there are mice with wheels. <\/p>\n<p> When the operating system starts up, it tries to figure out whether the mouse has a wheel and convinces it to go into wheel mode.  (You can influence this negotiation from Device Manager.) If both sides agree on wheeliness, then the mouse generates <strong>four<\/strong> bytes for each mouse motion, which therefore must be interpreted something like this: <\/p>\n<p> <u>x y b w<\/u> <u>x y b w<\/u> <u>x y b w<\/u> <u>x y b w<\/u> <\/p>\n<p> Now things get <strong>really<\/strong> interesting when you introduce laptops into the mix. <\/p>\n<p> Many laptop computers have a PS\/2 mouse port into which you can plug a mouse on the fly.  When this happens, the built-in pointing device is turned off and the PS\/2 mouse is used instead.  This happens <strong>entirely within the laptop&#8217;s firmware<\/strong>.  The operating system has no idea that this switcheroo has happened. <\/p>\n<p> Suppose that when you turned on your laptop, there was a wheel mouse connected to the PS\/2 port.  In this case, when the operating system tries to negotiate with the mouse, it sees a wheel and puts the mouse into &#8220;wheel mode&#8221;, expecting (and fortunately receiving) four-byte packets. <\/p>\n<p> Now unplug your wheel mouse so that you revert to the touchpad, and let&#8217;s say your touchpad doesn&#8217;t have a wheel. The touchpad therefore spits out three-byte mouse packets when you use it.  Uh-oh, now things are really messed up. <\/p>\n<p> The touchpad is sending out three-byte packets, but the operating system thinks it&#8217;s talking to that mouse that was plugged in originally and continues to expect four-byte packets. <\/p>\n<p> You can imagine the mass mayhem that ensues. <\/p>\n<p> Moral of the story: If you&#8217;re going to hot-plug a mouse into your laptop&#8217;s PS\/2 port, you have a few choices. <\/p>\n<ul>\n<li>Always use a nonwheel mouse, so that you can plug     and unplug with impunity, since the nonwheel mouse     and the touchpad both use three-byte packets. <\/li>\n<li>If you turn on the laptop with no external mouse,     then you can go ahead and plug in either a wheeled     or wheel-less mouse.  Plugging in a wheel-less mouse     is safe because it generates three-byte packets just     like the touchpad.  And plugging in a wheeled mouse     is safe because the wheeled mouse was not around     for the initial negotiation, so it operates in     compatibility mode (i.e., it pretends to be a     wheel-less mouse).  In this case, the mouse works,     but you lose the wheel. <\/li>\n<li>If you turn on the laptop with a wheel mouse plugged     in, <strong>never unplug it<\/strong> because once     you do, the touchpad will take over and send three-byte     packets and things will go berzerk. <\/li>\n<\/ul>\n<p> Probably the easiest way out is to avoid the PS\/2 mouse entirely and just use a USB mouse. This completely sidesteps the laptop&#8217;s PS\/2 switcheroo. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Each time you move a PS\/2-style mouse, the mouse send three bytes to the computer. For the sake of illustration, let&#8217;s say the three bytes are x, y, and buttons. The operating system sees this byte stream and groups them into threes: x y b x y b x y b x y b Now [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[104],"class_list":["post-37833","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-tipssupport"],"acf":[],"blog_post_summary":"<p>Each time you move a PS\/2-style mouse, the mouse send three bytes to the computer. For the sake of illustration, let&#8217;s say the three bytes are x, y, and buttons. The operating system sees this byte stream and groups them into threes: x y b x y b x y b x y b Now [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=37833"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/37833\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=37833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=37833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=37833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}