I have an application on win7 which needs to support touch and mouse input using monogame. But reading touch taps proves to be a very hard thing.
The TouchPanel is initialized like this:
TouchPanel.EnableMouseTouchPoint = true;
TouchPanel.EnabledGestures = GestureType.Tap | GestureType.DoubleTap | GestureType.Hold | GestureType.Pinch |
GestureType.FreeDrag | GestureType.DragComplete | GestureType.Flick | GestureType.HorizontalDrag |
GestureType.VerticalDrag;
TouchPanel.EnableMouseGestures = true;
Without EnableMouseTouchPoint and EnableMouseGestures there is no reaction from the touchscreen. Enabling both will at least get me touch locations and gestures on drag moves (this already makes me think that there is something essential missing here).
I have the following code to read input which is called on every Update:
private void GetInput(GameTime gameTime)
{
var gesture = default(GestureSample);
MouseState mouseState = Mouse.GetState();
TouchCollection touchCol = TouchPanel.GetState();
foreach (var touch in touchCol)
{
Console.WriteLine(touch.Position);
}
while (TouchPanel.IsGestureAvailable)
{
gesture = TouchPanel.ReadGesture();
Console.WriteLine(gesture.GestureType);
if (gesture.GestureType == GestureType.Tap)
{
DoHitTest(mouseState.X, mouseState.Y);
}
}
}
The touch collection will remain empty until the finger is dragged across the screen. Taps are not showing up. To get an actual tap i have to do a very short flick. In this case, there is a touch in the touch collection.
What am i missing? Am i doing something fundamentally wrong here?