Laptop touchpad tap

I found out that a double tap on touchpad is being recognized as a single one using Mouse.GetState() in Update() method. I tried to check it in the separated thread in while(true) statement. It worked but caused large increasing of CPU usage. Are there any solutions except using a third-party library for input?

afaik XNA/MG GetState only returns the state of the mouse (that’s pressed or not pressed). It doesnt’ return double clicks, nor actually clicks, nor gestures, so I’d say you’ll have to get them natively.

There’s a poor man’s alternative, that is just reading the MouseState each frame, and detect quick “press and release” (reading i.e. mouseState.LeftButton to change from Released to Pressed to Released in quick succession). That’s a click. If two come in fast succession, it’s a double click.

However this won’t work as expected if the clicks are too fast (never tried to do that, to be honest) or the framerate is too low, so I’d go native.

If your device is a touch device, you can use TouchPanel.ReadGesture to get gestures (that includes tap and double tap)

Not a great option, but you can put a sleep in the thread to soften the CPU usage, even if it is just 10ms.

Nope, i tried even 1 ms sleep but it was not enough.

Can you state the CPU model? just curious

I tried it on i3-5005u and i7-6700hq. It seems like it does not depend on CPU model.

1 Like

Yo man! It’s not that hard to create a mouse object with custom method and properties that can trap double clicks.

// On your initialize
_Mouse = new MouseDevice();
_Mouse.doubleClickSpeed = 300; // 300Ms

// On your game update

// On your game inquiry


If needed i can post my code implementation trapping double clicks ^_^y

Yes, I have noticed odd behavior using a TouchPad, it acts as a mouse like you stated. Before I just wrapped the mouse into a #Windows block. However this is not really viable.

For my code I’m going to check for the TouchPad first and ignore the mouse if the touchpad is in use. But that isn’t really going to cut it.

Any solutions would be nice.

I just used a wrapper for SDL2 with events like Window.TextInput and Window.ClientSizeChanged.

I think it’s even better than using default Monogame input.

This article states if MouseState.Left is pressed, it acts as the PRIMARY touch point. The reasons for this is uncertain if Microsoft’s Zune / Zune HD / Windows Phone 7 wasn’t capable of using a mouse or if it was required to get the touch to work. Either way Windows 10 and Windows 10 Mobile can use a mouse and touchpad, so, this may cause problems in your code.