microsoft / DirectXTK12

The DirectX Tool Kit (aka DirectXTK12) is a collection of helper classes for writing DirectX 12 code in C++
https://walbourn.github.io/directx-tool-kit-for-directx-12/
MIT License
1.45k stars 369 forks source link

Mouse needs to accumulate delta between calls to GetState #152

Closed walbourn closed 1 year ago

walbourn commented 1 year ago

For high-sensitivity mice, WM_INPUT is getting called multiple times per frame and the original implementation of RAW mouse for Win32 was only recording the most recent dx/dy. This change now accumulates delta from WM_INPUT in relative mode.

For this to work correctly, each time Mouse::GetState is called in relative movement mode, the accumulated delta is reset so the assumption is that this is called once per frame.

Since this does not cover all usage scenarios, there is new optional method for Mouse EndOfInputFrame that should be called once per render call. This turns off the 'auto-reset' behavior of GetState and instead clears it once per frame in this method instead.