Using MonoGame on DX template,
KeyboardState ks = Keyboard.GetState() in Game.Update override SUCCESSFULLY get updates to
Trying to do the equivalent in a custom class (not inherited from Game) in a project NOT built using a MonoGame template.
REASON: That’s the way this code was written years ago.
[I’ll change to a standard approach if I have to, but there should be some easy way to get this existing code to work.]
In my equivalent to Update, I call
(If I don’t, not surprisingly, KeyboardState never changes at all.)
VB code (verified is called many times per second, by incrementing a counter variable):
FrameworkDispatcher.Update() Dim ks As KeyboardState = Keyboard.GetState Dim keysN As Keys() = ks.GetPressedKeys() If keysN.Length > 0 OrElse ks.CapsLock Then Test() End If
Works: updates to
ks.CapsLock. <-- proving that SOME updating is occurring.
Doesn’t work: NO updates to ks.GetPressedKeys() - always returns an empty array.
If I put a breakpoint on line
Test(), then while holding “W”, press “CapsLock”,
I can examine the internal array and see that the keys all have value 0.
Q: Is there something I need to do early on, to initialize the keyboard input?
Or something else I need to do in addition to