Weird Input behavior, possibly related to frame rate

Hi again

I’m currently testing my game on virtualized Ubuntu.
If my fps is low, Input keeps happening for a while after I have released keys after holding them, and weird thing is that it thinks that I’m repeatedly pressing the keys instead of holding them.

Input system is nothing special: compare previous frame’s keyboard state to current frame’s state, and save the data to “pressed”, “released” and “held” bools.

Is this related to how MonoGame handles low frame rate, and is there way to stop this behavior?

So when you press a key MG reports frames with key down, then frames with key up, then frames with key down again even though you only pressed the key once? MonoGame lets SDL handle input in DesktopGL projects, which sends events when key up/down occurs. MG polls queued events every frame, so it should always have the latest key state at the frame start.

1 Like

Problem disappears when the game has good frame rate (50-60fps), again, this is on virtualized Ubuntu so this might also be related to that. I tested the game earlier on friend’s Linux computer, and it run without problems.

SynchronizeWithVerticalRetrace and IsFixedTimeStep are both true, and game targets 60fps.
I press key, game has short delay before moving Player based on the input, and when I release it keeps moving the Player for a random time, but the Input after that is seen as repeatedly pressing the buttons.

As far as I know, XNA (and so MonoGame) handles low framerate by calling Update multiple times while skipping Draw to save time, so it might or might not be related to that.

It is weird, but I don’t think that it is a problem as long as frame rate is consistent.