 
 M: dinput-game-input-backend reset-mouse
     +mouse-device+ get [ f MOUSE-BUFFER-SIZE read-device-buffer ]
-    [ 2drop ] [ ] with-acquisition ;
+    [ 2drop ] [ ] with-acquisition
+    +mouse-state+ get
+        0 >>dx
+        0 >>dy
+        0 >>scroll-dx
+        0 >>scroll-dy
+        drop ;

    GUID_SysMouse device-for-guid
    [ configure-mouse ]
    [ +mouse-device+ set-global ] bi
    0 0 0 0 8 <vector> mouse-state boa
    +mouse-device+ set-global ;
    MOUSE-BUFFER-SIZE "DIDEVICEOBJECTDATA" <c-array>
    +mouse-buffer+ set-global ;


    [ "DIDEVICEOBJECTDATA" heap-size ] 2dip <uint>
    [ 0 IDirectInputDevice8W::GetDeviceData ole32-error ] 2keep *uint ;

: (fill-mouse-state) ( state DIDEVICEOBJECTDATA -- state )
    [ DIDEVICEOBJECTDATA-dwData 32 >signed ] [ DIDEVICEOBJECTDATA-dwOfs ] bi {
        { DIMOFS_X [ [ + ] curry change-dx ] }
        { DIMOFS_Y [ [ + ] curry change-dy ] }
        { DIMOFS_Z [ [ + ] curry change-scroll-dy ] }
        [ [ c-bool> ] [ DIMOFS_BUTTON0 - ] bi* rot [ buttons>> set-nth ] keep ]
    } case ;

: fill-mouse-state ( buffer count -- state )
    [ +mouse-state+ get ] 2dip swap
    [ "DIDEVICEOBJECTDATA" byte-array>struct-array nth (fill-mouse-state) ] curry each ;

: get-device-state ( device byte-array -- )
    [ dup IDirectInputDevice8W::Poll ole32-error ] dip
