# Incorrect mouse motion

**URL:** <https://discourse.libsdl.org/t/incorrect-mouse-motion/6303>\
**Category:** SDL Development\
**Created:** [March 27, 2002, 9:40pm UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303 "2002-03-27T21:40:01Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Lagerquist](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/77aa72/32.png) [@John\_Lagerquist](https://discourse.libsdl.org/u/John_Lagerquist)\
**Post date:** [March 27, 2002, 9:40pm UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/1 "2002-03-27T21:40:01Z")

</div>

I am new to SDL.

I am experiencing a problem with the absolute mouse position in win2k, I am  
working in openGL. I am processing the SDL\_MOUSEMOTION message. When I  
move the mouse slowly, the coords track correctly, but when I move the mouse  
quickly from left to right they are off by up to 500 pixels by the time I  
reach the right side of the screen. If I then again move the mouse slowly,  
I still do not get the proper coords indicating that it is not a case of my  
event polling loop not keeping up with the mouse. Any ideas?

```
    case SDL_MOUSEMOTION:
        if ( dragActive )
        {
            dx = event.motion.xrel;
            dy = event.motion.yrel;
        } else
        {
            mx = event.motion.x;
            my = event.motion.y;
        }
        break;

```

John

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [March 28, 2002, 8:23am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/2 "2002-03-28T08:23:02Z")

</div>

> I am new to SDL.

> I am experiencing a problem with the absolute mouse position in win2k, I am  
> working in openGL. I am processing the SDL\_MOUSEMOTION message. When I  
> move the mouse slowly, the coords track correctly, but when I move the mouse  
> quickly from left to right they are off by up to 500 pixels by the time I  
> reach the right side of the screen. If I then again move the mouse slowly,  
> I still do not get the proper coords indicating that it is not a case of my  
> event polling loop not keeping up with the mouse. Any ideas?

It’s a bug that I haven’t been able to solve. It appears to be something  
involved with the mouse driver in Windows, but I have no idea why it would  
happen only in OpenGL mode.

Any ideas anyone?

See ya,  
-Sam Lantinga, Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![IronRaph\_at\_aol.com](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/i/7ea924/32.png) [@IronRaph\_at\_aol.com](https://discourse.libsdl.org/u/IronRaph_at_aol.com)\
**Post date:** [March 28, 2002, 8:41am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/3 "2002-03-28T08:41:01Z")

</div>

i think that SDL have some troubles with mouse uder win32

---

<div class="post-metadata">

**Author:** ![Steve\_Lupton](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/df788c/32.png) [@Steve\_Lupton](https://discourse.libsdl.org/u/Steve_Lupton)\
**Post date:** [March 28, 2002, 8:55am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/4 "2002-03-28T08:55:00Z")

</div>

Hi

All I can add is that I tried and failed to resolve this.

We ended up using our app in pseudo full screen mode (A 1024 x 768 window  
with SDL\_NOFRAME specified and the Windows taskbar not set to be always on  
top).

The exact problem is that the mouse co-ordinates behave as if the screen  
resolution is 640 x 480 when using OpenGL in fullscreen mode. The 640 x 480  
“window” then pans around to follow the cursor!

I believe this question has been asked quite a few times in the past with no  
satisfactory resolution.

Regards,

Steve\> ----- Original Message -----

> From: Sam Lantinga [[mailto:slouken@devolution.com](mailto:slouken@devolution.com)]  
> Sent: 28 March 2002 16:22  
> To: sdl at [libsdl.org](http://libsdl.org)  
> Subject: Re: [SDL] Incorrect mouse motion…
> 
> > I am new to SDL.
> 
> > I am experiencing a problem with the absolute mouse position in win2k, I  
> > am  
> > working in openGL. I am processing the SDL\_MOUSEMOTION message. When I  
> > move the mouse slowly, the coords track correctly, but when I move the  
> > mouse  
> > quickly from left to right they are off by up to 500 pixels by the time I  
> > reach the right side of the screen. If I then again move the mouse  
> > slowly,  
> > I still do not get the proper coords indicating that it is not a case of  
> > my  
> > event polling loop not keeping up with the mouse. Any ideas?
> 
> It’s a bug that I haven’t been able to solve. It appears to be something  
> involved with the mouse driver in Windows, but I have no idea why it would  
> happen only in OpenGL mode.
> 
> Any ideas anyone?
> 
> See ya,  
> -Sam Lantinga, Software Engineer, Blizzard Entertainment
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)
> 
> * * *
> 
> This email and any files transmitted with it are confidential and  
> intended solely for the use of the individual or entity to whom they  
> are addressed. If you have received this email in error please notify  
> the system manager.
> 
> This footnote also confirms that this email message has been swept by  
> MIMEsweeper for the presence of computer viruses.
> 
> [www.mimesweeper.com](http://www.mimesweeper.com)
> 
> * * *

---

<div class="post-metadata">

**Author:** ![Jason\_Hoffoss](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/a9adbd/32.png) [@Jason\_Hoffoss](https://discourse.libsdl.org/u/Jason_Hoffoss)\
**Post date:** [March 28, 2002, 9:00am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/5 "2002-03-28T09:00:00Z")

</div>

> > > I am new to SDL.
> > 
> > > I am experiencing a problem with the absolute mouse position in win2k, I  
> > > am  
> > > working in openGL. I am processing the SDL\_MOUSEMOTION message. When I  
> > > move the mouse slowly, the coords track correctly, but when I move the  
> > > mouse  
> > > quickly from left to right they are off by up to 500 pixels by the time  
> > > I  
> > > reach the right side of the screen. If I then again move the mouse  
> > > slowly,  
> > > I still do not get the proper coords indicating that it is not a case of  
> > > my  
> > > event polling loop not keeping up with the mouse. Any ideas?
> > 
> > It’s a bug that I haven’t been able to solve. It appears to be something  
> > involved with the mouse driver in Windows, but I have no idea why it would  
> > happen only in OpenGL mode.
> > 
> > Any ideas anyone?
> 
> Sounds like it’s reading the motion counters directly, and not accounting  
> for acceleration.
> 
> -Jason
> 
> > ----- Original Message -----  
> > From: [slouken@devolution.com](mailto:slouken@devolution.com) (Sam Lantinga)  
> > To:   
> > Sent: Thursday, March 28, 2002 11:22 AM  
> > Subject: Re: [SDL] Incorrect mouse motion…

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [March 28, 2002, 9:05am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/6 "2002-03-28T09:05:01Z")

</div>

> i think that SDL have some troubles with mouse uder win32

Have you had any other troubles? As far as I know, that’s the only problem.

```
-Sam Lantinga, Software Engineer, Blizzard Entertainment

```

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [March 28, 2002, 9:06am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/7 "2002-03-28T09:06:00Z")

</div>

> Sounds like it’s reading the motion counters directly, and not accounting  
> for acceleration.

That could be it, but why wouldn’t it happen under DirectX fullscreen mode?  
Does going into GL change the input somehow?  
If mouse acceleration is turned off, how can we tell, and how can we either  
turn it back on or do the acceleration ourselves?

See ya,  
-Sam Lantinga, Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![EvilTypeGuy](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@EvilTypeGuy](https://discourse.libsdl.org/u/EvilTypeGuy)\
**Post date:** [March 28, 2002, 9:22am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/8 "2002-03-28T09:22:01Z")

</div>

I’ve experienced this problem in twilight as well, although with a different item,  
and that is mousewheel behavior. (Mercury) Zephaniah Hull (one of our team members),  
has discovered that it has something to do with using windib vs. directinput with  
OpenGL, and why it affects only SDL he’s still trying to figure out at last check.

I’ve seen the acceleration problem too under Win XP, although never under Win98SE.

If someone could make SDL use windib for input instead of directinput and see if  
the acceleration problem still exists, that might be an interesting test…

-EvilTypeGuyOn Thu, Mar 28, 2002 at 08:22:20AM -0800, Sam Lantinga wrote:

> > I am new to SDL.
> 
> > I am experiencing a problem with the absolute mouse position in win2k, I am  
> > working in openGL. I am processing the SDL\_MOUSEMOTION message. When I  
> > move the mouse slowly, the coords track correctly, but when I move the mouse  
> > quickly from left to right they are off by up to 500 pixels by the time I  
> > reach the right side of the screen. If I then again move the mouse slowly,  
> > I still do not get the proper coords indicating that it is not a case of my  
> > event polling loop not keeping up with the mouse. Any ideas?
> 
> It’s a bug that I haven’t been able to solve. It appears to be something  
> involved with the mouse driver in Windows, but I have no idea why it would  
> happen only in OpenGL mode.
> 
> Any ideas anyone?
> 
> See ya,  
> -Sam Lantinga, Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![John\_Lagerquist](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/77aa72/32.png) [@John\_Lagerquist](https://discourse.libsdl.org/u/John_Lagerquist)\
**Post date:** [March 28, 2002, 4:51pm UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/9 "2002-03-28T16:51:01Z")

</div>

Hmmm, my mouse wheel seems to be working correctly in Win2k. What mouse  
wheel behaviour are you seeing?

John\> ----- Original Message -----

> From: [eviltypeguy@qeradiant.com](mailto:eviltypeguy@qeradiant.com) (EvilTypeGuy)
> 
> > I’ve experienced this problem in twilight as well, although with a  
> > different item,  
> > and that is mousewheel behavior.

---

<div class="post-metadata">

**Author:** ![John\_Lagerquist](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/77aa72/32.png) [@John\_Lagerquist](https://discourse.libsdl.org/u/John_Lagerquist)\
**Post date:** [March 28, 2002, 4:54pm UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/10 "2002-03-28T16:54:01Z")

</div>

Steve,

> The exact problem is that the mouse co-ordinates behave as if the screen  
> resolution is 640 x 480 when using OpenGL in fullscreen mode. The 640 x  
> 480  
> “window” then pans around to follow the cursor!

This is exactly the problem that I appear to be having. I am running in  
1280x1024. I think the others are correct in that it has to do with  
acceleration. If I move the mouse VERY slowly, it tracks correctly. Maybe  
SDL is not the way to go for my application. It is critical that I have  
accurate mouse positioning.

John

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [March 29, 2002, 12:23am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/11 "2002-03-29T00:23:01Z")

</div>

> This is exactly the problem that I appear to be having. I am running in  
> 1280x1024. I think the others are correct in that it has to do with  
> acceleration. If I move the mouse VERY slowly, it tracks correctly. Maybe  
> SDL is not the way to go for my application. It is critical that I have  
> accurate mouse positioning.

Like I said, this is a bug (in fact the only bug holding up SDL 1.2.4),  
so as soon as somebody figures out how to fix it, we will.

See ya,  
-Sam Lantinga, Software Engineer, Blizzard Entertainment

---

<div class="post-metadata">

**Author:** ![EvilTypeGuy](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@EvilTypeGuy](https://discourse.libsdl.org/u/EvilTypeGuy)\
**Post date:** [March 29, 2002, 7:35am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/12 "2002-03-29T07:35:01Z")

</div>

The mouse wheel stops working in our SDL app under Windows XP for me, I haven’t  
personally tried Windows 2000 but we’ve had some reports from some win2k users.

Basically, we roll the mousewheel once and suddenly no more mousewheel. This  
doesn’t happen when running the application under Linux or Windows 98…

-EvilTypeGuyOn Thu, Mar 28, 2002 at 07:48:48PM -0500, John Lagerquist wrote:

> Hmmm, my mouse wheel seems to be working correctly in Win2k. What mouse  
> wheel behaviour are you seeing?
> 
> John
> 
> ----- Original Message -----  
> From: “EvilTypeGuy”
> 
> > I’ve experienced this problem in twilight as well, although with a  
> > different item,  
> > and that is mousewheel behavior.
> 
> * * *
> 
> SDL mailing list  
> SDL at [libsdl.org](http://libsdl.org)  
> [http://www.libsdl.org/mailman/listinfo/sdl](http://www.libsdl.org/mailman/listinfo/sdl)

---

<div class="post-metadata">

**Author:** ![IronRaph\_at\_aol.com](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/i/7ea924/32.png) [@IronRaph\_at\_aol.com](https://discourse.libsdl.org/u/IronRaph_at_aol.com)\
**Post date:** [March 29, 2002, 9:37am UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/13 "2002-03-29T09:37:01Z")

</div>

the probleme is with mouse acceleration if you disable mouse acceleration the  
mouse coordinates and motion will be ok

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [March 30, 2002, 6:46pm UTC](https://discourse.libsdl.org/t/incorrect-mouse-motion/6303/14 "2002-03-30T18:46:01Z")

</div>

Okay, thanks to everyone’s help, this bug has been fixed.  
You can grab the fix in the latest CVS snapshot:  
[http://www.libsdl.org/cvs.html](http://www.libsdl.org/cvs.html)

Thanks!  
-Sam Lantinga, Software Engineer, Blizzard Entertainment
