[Solved] Not register fast mouse clicks


This is a weird one that is most likely not a Monogame problem. Im asking here anyways because maybe someone have had the same problem.

When i do a fast click on the mouse buttons under the touchpad or tapping the touchpad on my laptop it wont register. A longer press do register but it’s enough of a problem to make coding a decent double click imposible.

     mouseState = Mouse.GetState();
        if(mouseState.LeftButton == ButtonState.Pressed)
            Console.WriteLine("pressed" + gameTime.TotalGameTime.Ticks);

I tried it on a different computer and it works fine so this is probably a computer/driver/os thing but “fast clicking” works everywhere except in a compiled monogame project.

This is what i have deducted by different tests:

  • Updated, Reinstalled, Restarted Drivers and Computer don’t help.
  • I tried it on a different laptop and everything works fine.
  • Connecting a mouse works fine
  • I have like 2 sets of ”mouse” buttons on the “problem” laptop and one works and the other don’t. (see image)
  • In Windows and applications fast clicking/tapping works fine.
  • Windows and Cross Platform project template dont work.
  • Simulating an android device tapping and mouse clicking works (but this is different code ofc) i’m just mentioning this if to illustrate that i think the driver is working… ish.


  • Have you heard of this problem at all?
  • Any way i can rule out monogame as the problem 100%?
  • Do any of you have a ide what i can try to make fast clicking work on my faulty laptop?

Input like this works best if you compare the current state of the mouse to the state from a previous frame. Right now the code is checking if the left mouse button is held and not accounting for if it was just pressed. Here’s an example:

//Reference state that's updated once at the end of each frame
public static MouseState mState = new MouseState();

public static void HasLeftClicked()
    //Get the current state of the mouse
    MouseState mouseState = Mouse.GetState();
    //Compare the current state of the mouse with the reference state
    //If the mouse WASN'T pressed last frame and IS pressed now, print this message
    if (mState.LeftButton == ButtonState.Released && mouseState.LeftButton == ButtonState.Pressed)
        Console.WriteLine("Left mouse button just pressed");

//Called once at the end of each frame to update the reference state
public static void UpdateMState()
    mState = Mouse.GetState();

I’m not entirely sure what’s going on with the buttons on your laptop, but I hope this helps. It should work for all standard types of mouse clicks.

Yes you are absolutely correct. I just wanted to make sure the the code was as simple as possible to check if i could press the left mouse button without WriteLine to the console happening.

And tapping the touchpad or the left button below i can indeed do that reliable every time.

Now when i Google this problem i do not get any good leads so i concluded: Im either the first one that ever encountered this problem in the world or i messed something up that is so simple to solve its not worth recording anywhere on the internet… its the latter! :slight_smile:

Monogame has a bad design in the input model where if there’s lag it can drop inputs. I’m a bit skeptical that is whats causing your problem because you shouldn’t be having any lag but I wrote about it here if you want to check it out http://hernblog.com/blogs/fixingInputInWindowsMonogame.html

Also if you hook directly into DirectX per my blog post you could find out the problem was in the monogame engine or not.

The latest develop has cross-platform OnKeyDown and OnKeyUp events in GameWindow. I don’t believe there are events for mouse, though.

Dunno if this will help and im not going to claim this is the prettiest or most intuitive mouse class to look at or that after so many years i shouldn’t have made it look nicer or even added more stuff i probably should have however… I guess the fact i used it for so long without bothering to change it says something.

It’s not timed, its a logic based mouse class that uses iterations of the update to figure out exactly what is being done.

It recognizes all the following distinctions for the left and right mouse buttons

Clicked // registers the frame it happens
Down // this registers if the button is down for at least 2 frames.
JustReleased // eg after being held or the ending position of a drag.
PressedAt // this only counts the initial position at the start of a drag.
DragVector() // the directional vector of the drag.

virtual position // as a ratio of the screen width height you have to pass the screen width height for that.
wheeling Up Down or AtRest.
prevent mulitple updates // isn’t required its redundant i never use it.
You can print all the bools to screen if your not sure exactly when things fire including making a rectangle from the start and end drag clicks.

to use it you just call UserMouseInput.Update() in your game1 update method.

I’d say you’ve already solved your problem. If you tested with multiple input devices and one works and another doesn’t, almost certainly concludes it as a hardware problem. AFAIK Monogame grabs all its inputs from Windows’ message pump(or other OS equivalent I guess). Which inputs Windows relays is largely going to be based on the drivers and/or performance of the device itself. Windows will just send over the input messages to Monogame the same regardless.

That said, if you’re already doing previous/current input state comparisons to check for changes in input state every frame, that’s about the best you can do in Monogame, short of writing your own input state class which circumvents Monogame’s own implementation and communicates directly with the OS.

But yeah, I don’t imagine that’s your issue.

Laptop input devices are finnicky at the best of times in my personal experience. Maybe try a few other mice if you have any lying around. Or plug in a USB keyboard or something. If all of those are working and it’s just the laptop’s touch pad/clickers… it’s probably just the laptop unfortunately. Worn out contact points and connectors are a thing.

[quote=“Rei, post:7, topic:11869”]
I’d say you’ve already solved your problem. If you tested with multiple input devices and one works and another doesn’t, almost certainly concludes it as a hardware problem.[/quote]
This is my call as well and wouldn’t have bothered posting if it wasn’t for the fact that the button works everywhere else in the windows.

Oh this gave my an idee! I just made a windows form project and added a button and lo and behold the same “problem”.

Im now super confident this is a VS/driver/os/dll problem (as all of you and me suspected). As connecting a mouse to my dev laptop circumvents the problem all together i’ll mark this thread as solved.

Thank you all for support and suggestions.

1 Like