 : find-keyboard ( -- )
     GUID_SysKeyboard device-for-guid
     [ configure-keyboard ]
-    [ +keyboard-device+ set-global ] bi ;
+    [ +keyboard-device+ set-global ] bi
+    256 <byte-array> <keys-array> keyboard-state boa
+    +keyboard-state+ set-global ;
 
 : device-info ( device -- DIDEVICEIMAGEINFOW )
     "DIDEVICEINSTANCEW" <c-object>

    handle>> f 0 IDirectInputDevice8W::RunControlPanel ole32-error ;

M: dinput-game-input-backend read-keyboard
    +keyboard-device+ get [ 256 get-device-state ]
    [ <keyboard-state> ] [ f ] with-acquisition ;

dinput-game-input-backend game-input-backend set-global


: release-keyboard ( -- )
    +keyboard-device+ global
    [ com-release f ] change-at
    f +keyboard-state+ set-global ;

M: dinput-game-input-backend (open-game-input)
    create-dinput
