# Inaccurate mouse movement in OSX?

**URL:** <https://discourse.glfw.org/t/inaccurate-mouse-movement-in-osx/228>\
**Category:** support\
**Created:** [May 29, 2012, 11:37am UTC](https://discourse.glfw.org/t/inaccurate-mouse-movement-in-osx/228 "2012-05-29T11:37:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [May 29, 2012, 11:37am UTC](https://discourse.glfw.org/t/inaccurate-mouse-movement-in-osx/228/1 "2012-05-29T11:37:06Z")

</div>

**[mwaness](https://sourceforge.net/u/mwaness/)** wrote on [Tuesday, May 29, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/91ed8dcb/#89a3):

Hi,  
I’ve been using the following code to create a FPS style camera movement in my  
program.  
On Windows and Linux, the results are smooth, but when I tried porting to OSX,  
I got extremely jagged movements, with no input for about a second, then a  
burst of (small) movement, then no input again.  
Am I doing something wrong?

```
    // Mouse events
    if (glfwGetWindowParam(GLFW_ACTIVE) == GL_TRUE) {
        if (lostFocus) {
            lostFocus = false;
            // Reset the mouse for the next call
        } else {
            int x = 0, y = 0;
            glfwGetMousePos(&x, &y);
            data.DeltaViewX = static_cast<float>(x - centerx);
            data.DeltaViewY = static_cast<float>(y - centery);
        }
        glfwSetMousePos(centerx, centery);
    } else {
        // Ignore the mouse if the window's not in focus.
        lostFocus = true;
    }
```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [May 29, 2012, 2:37pm UTC](https://discourse.glfw.org/t/inaccurate-mouse-movement-in-osx/228/2 "2012-05-29T14:37:28Z")

</div>

**[elmindreda](https://sourceforge.net/u/elmindreda/)** wrote on [Tuesday, May 29, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/91ed8dcb/#f616):

Instead of centering the mouse cursor manually, you should likely be using the  
GLFW\_MOUSE\_CURSOR enable.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/glfw/original/1X/b8cdefe6b61b8d5aee6c43b2c56e9cf5eabecfe4.svg) [@system](https://discourse.glfw.org/u/system)\
**Post date:** [May 30, 2012, 6:05pm UTC](https://discourse.glfw.org/t/inaccurate-mouse-movement-in-osx/228/3 "2012-05-30T18:05:48Z")

</div>

**[mwaness](https://sourceforge.net/u/mwaness/)** wrote on [Wednesday, May 30, 2012](https://sourceforge.net/p/glfw/discussion/247562/thread/91ed8dcb/#8e7a):

Odd, I’m sure I remember that directive only being available for fullscreen  
contexts.  
That solved it though, thanks!
