Best way to implement keyboard and mouse events

How to implement a mouse down and mouse up events? Should I poll a mouse state and compute the difference? In this case could be some missing events especially on a low fps.

I guess in all thw backends there is a event-driven input system under the hood. So what is the purpose of creating state-driven system in a top of it hiding original events? Does monogame team have some plants to implement input events?

I have an input manager in my nuget packages, just search for MonoGame.Randomchaos.Sevices.Input.

Or you can get the code here.

Not done a sample just for input yet, but most of my samples in that repo, if not all use it.

Hope this helps.

2 Likes

How it works in a nitshell?

Its an input setvice you can use throuout your Game.

When you initialize it with one or all, keyboard manager, mouse manager, gamepad manager or touch manager.

You can then use the service to take inputs frome all.

It will manage key/mose/button down as well as press.

Ill do a sample just for input at some point, but as i say all the samples in that repo use it.

I made this input library. I use it in all my projects.

There’s a getting started guide so you can see if you like the style.

polling on update is totally fine. You shouldn’t even think about low fps/ups. Check your Update-Loop, optimize every algo and if you can’t optimize them any further, use tasks for things that are inherently slow. If you go sub 30 fps/ups, i doubt your users will enjoy the experience anyway and 30ups is 33ms between updates, that should still be enough to catch mouse up and down.