# High precision mouse input

**URL:** <https://discourse.glfw.org/t/high-precision-mouse-input/912>\
**Category:** support\
**Created:** [May 14, 2017, 1:34am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912 "2017-05-14T01:34:55Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Infinity95](https://avatars.discourse-cdn.com/v4/letter/i/ee59a6/32.png) [@Infinity95](https://discourse.glfw.org/u/Infinity95)\
**Post date:** [May 14, 2017, 1:34am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/1 "2017-05-14T01:34:55Z")

</div>

I’m experimenting and trying out the different GLFW features and am currently wondering if there is sub pixel precision on windows platforms.  
I found [this](https://msdn.microsoft.com/en-us/library/windows/desktop/ee418864(v=vs.85).aspx) that says it’s possible.  
I tried the different cursor modes but always get per pixel values.  
Is it just not supported on windows, or am i doing something wrong?

EDIT: If it’s relevant: I have a Logitech G502 mouse, which i used to test the mouse callbacks.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 14, 2017, 9:46am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/2 "2017-05-14T09:46:25Z")

</div>

[Raw mouse input](https://github.com/glfw/glfw/issues/125) has been added for the case when the cursor is disabled, and it’s available in the in-progress code from [Github](https://github.com/glfw/glfw) but not yet in an official release.

---

<div class="post-metadata">

**Author:** ![Infinity95](https://avatars.discourse-cdn.com/v4/letter/i/ee59a6/32.png) [@Infinity95](https://discourse.glfw.org/u/Infinity95)\
**Post date:** [May 14, 2017, 9:52am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/3 "2017-05-14T09:52:07Z")

</div>

I this on the master branch? Because i am using the master branch, but don’t seem to get the desired behavior.  
I pulled the most recent changes from master and recompiled just to be sure, but there was no change.

EDIT: I tried all different cursor modes with the same result of per pixel movement. Is this input mode only dependant on the set cursor mode (cursor disabled)?

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 14, 2017, 10:07am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/4 "2017-05-14T10:07:00Z")

</div>

WM\_INPUT is only used when GLFW\_CURSOR\_DISABLED is set, [see the glfw Windows message handler in win32\_window.c on master branch](https://github.com/glfw/glfw/blob/master/src/win32_window.c#L662).

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [May 14, 2017, 11:05am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/5 "2017-05-14T11:05:50Z")

</div>

That MSDN page does imply that it provides sub-pixel motion, but as far as I’ve been able to tell it doesn’t.

What it does provide and what GLFW now supports in master is _unfiltered_ motion, i.e. no acceleration or other effects have been applied to it, making it more suitable for camera controls.

---

<div class="post-metadata">

**Author:** ![Infinity95](https://avatars.discourse-cdn.com/v4/letter/i/ee59a6/32.png) [@Infinity95](https://discourse.glfw.org/u/Infinity95)\
**Post date:** [May 14, 2017, 11:21am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/6 "2017-05-14T11:21:40Z")

</div>

Yes, im using GLFW\_CURSOR\_DISABLED as i mentioned earlier.

@elmindreda Interesting. Just another question: The glfw functions as i understand always return a cursor position. Is there an alternative that supplies deltas, or do i have to do that myself (would’nt be a problem, but if there already is functionality for this, why not use it).

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [May 14, 2017, 11:33am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/7 "2017-05-14T11:33:57Z")

</div>

You need to calculate the delta yourself.

---

<div class="post-metadata">

**Author:** ![Infinity95](https://avatars.discourse-cdn.com/v4/letter/i/ee59a6/32.png) [@Infinity95](https://discourse.glfw.org/u/Infinity95)\
**Post date:** [May 14, 2017, 11:45am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/8 "2017-05-14T11:45:52Z")

</div>

Thank you for the answers!

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 14, 2017, 11:55am UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/9 "2017-05-14T11:55:26Z")

</div>

Experimentation on my system with my mouse settings, with GLFW\_CURSOR\_DISABLED a vertical motion of ~25mm gives me a delta of 1000 whereas I need a vertical motion of 50mm to get the same delta without GLFW\_CURSOR\_DISABLED. So for my settings I get ~2x the precision from WM\_INPUT.

The mouse I used for the test has 1000dpi resolution, which is consistent with the 1000 delta for 25mm as an inch ~25mm.

---

<div class="post-metadata">

**Author:** ![Infinity95](https://avatars.discourse-cdn.com/v4/letter/i/ee59a6/32.png) [@Infinity95](https://discourse.glfw.org/u/Infinity95)\
**Post date:** [May 14, 2017, 12:24pm UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/10 "2017-05-14T12:24:59Z")

</div>

I see absolutely no difference with my 1200 dpi mouse. With cursor disabled i get the same as when it is enabled with various settings of dpi (tested with 400 dpi, 800 dpi and 1200 dpi)  
My mouse settings are as follows: The pointer speed in windows is set to neutral (the middle bar) and i have acceleration off.  
So basically i guess all the raw input does is take away the mouse accel and the pointer speed set in the settings.

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [May 14, 2017, 12:44pm UTC](https://discourse.glfw.org/t/high-precision-mouse-input/912/11 "2017-05-14T12:44:14Z")

</div>

Using raw input can only give you as much precision as your hardware. If  
you measure distance to deltas with your different mice do you see the same  
results as their dpi resolution when using raw input?
