Glfw: Jerky mouse position with GLFW_CURSOR_DISABLED

Created on 19 May 2018  路  2Comments  路  Source: glfw/glfw

Hello,

I believe I've stumbled upon a bug with virtual mouse position provided when the cursor is disabled. I use the feature as follows:

  1. on mouse button clicked callback - when pressed:

    • save received mouse position as prevMousePos

    • set input mode for the cursor to GLFW_CURSOR_DISABLED

  2. on mousemove callback:

    • if we are in moving mode (e.g. mouse button is down)



      • get delta as mousePos - prevMousePos


      • do something with the delta


      • update prevMousePos



  3. on mouse button clicked callback - when released:

    • reset input mode for the cursor to GLFW_CURSOR_NORMAL

I notice sometimes when I move the mouse and press at the same time (instead of pressing and waiting a little bit before moving) the delta in step 2. is super large and for the first mouse move event is always offset by lastMousePress (i.e. last value from step 1) minus windowSize/2, instead of some low expected value, like a few pixels around the lastMousePress. This gives a super large delta on the first mouse move if the click was done near the borders of the window. I believe the error comes somewhere in ordering of events, whether its WM_INPUT or WM_MOUSEMOVE being triggered in an order where the internal virtual cursor tracking is not properly initialized, but I couldn't find the bug in the library source myself.

Full example for window size [800, 600]:

  1. Mouse pressed at [700, 100]
  2. First mousemove is at [1000, -100]. It is equal to [700, 100] + [700, 100] - [400, 300]. But I'd expect it to be around [700, 100]. Then every subsequent mouse move is also around this "wrong" value.
  3. Mouse release is also triggered at this value (around [1000, -100], depends on where exactly I release)

Platform: Win10

Windows bug

Most helpful comment

Maybe related to Windows 10 Fall Creators Update mouse issue: https://twitter.com/icculus/status/941912950188765184

I would recommend cloning latest GLFW from master which should use raw input which might circumvent this bug and/or updating Windows

All 2 comments

Maybe related to Windows 10 Fall Creators Update mouse issue: https://twitter.com/icculus/status/941912950188765184

I would recommend cloning latest GLFW from master which should use raw input which might circumvent this bug and/or updating Windows

Greetings,

Thanks for the tips.
I've built the lib from master branch and it seems to be working correctly, I couldn't reproduce the error.

I'll close the issue.

Was this page helpful?
0 / 5 - 0 ratings