VSync affecting keyboard input?

Ok, so… I’ve touched on this quite a few times before here… In my efforts to get rid of the “hitching” prevalent in XNA/MonoGame (especially noticeable in a 2D sidescroller) while still using a fixed time step I’ve come up with the following solution:

In Game1 class add:

protected override bool BeginDraw() {
return false;

This will inhibit the default draw calls. With isFixedTimeStep = true the logic calls Draw() “whenever they feel like it,” to quote one of the developers of XNA. So, you are not guaranteed a Draw() call for each Update() call.

Then, add this to the end of the Update method:

if (base.BeginDraw()) {

This will give you a Draw() call after each Update(). It will be up to you to make sure that your code runs inside of the TargetElapsedTime for each frame.

This works wonderfully as long as your Update() an Draw() methods execute inside of the TargetElapsedTime window. The only caveat has been that keyboard input becomes sluggish/unresponsive. Controller input is unaffected, which has always puzzled me. Anyway, today I figured out that if I turn off vsync:

graphics.SynchronizeWithVerticalRetrace = false;

keyboard input is no longer affected and 100% responsive. So… does anyone have any insight as to why turning on vsync would impact the keyboard input but not the gamepad input? I’d be fine with just leaving vsync off, but I get terrible screen tearing without it. I’m not sure if it’s an issue with my graphics card (Radeon RX 480) or my monitor. Either way, it’s unacceptable and I don’t want others to have the issue. I appreciate any insight!

1 Like