On-screen touch recognition, such as MouseDown

1

I'm developing a game (Puzzle) in C # WinForms, to run on a touch screen. The mapping of ring events to the mouse events already occurs by default, and I did not have to do anything to make that happen. However, the mouse_down only occurs when I move my finger a little, and it does not occur in the precise moment when I touch the screen.

Why is this happening? Should I implement some kind of touch event recognition?

    
asked by anonymous 29.05.2014 / 20:29

1 answer

0

Other problems have arisen, however, such as the overlap and difficulty of distinguishing between touch and mouse events, but the above problem solved the following:

protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case Win32.WM_POINTERDOWN:
            case Win32.WM_POINTERUP:
            case Win32.WM_POINTERUPDATE:
            case Win32.WM_POINTERCAPTURECHANGED:
                break;

            default:
                base.WndProc(ref m);
                return;
        }
        int pointerID = Win32.GET_POINTER_ID(m.WParam);
        Win32.POINTER_INFO pi = new Win32.POINTER_INFO();
        if (!Win32.GetPointerInfo(pointerID, ref pi))
        {
            Win32.CheckLastError();
        }
        Point pt = PointToClient(pi.PtPixelLocation.ToPoint());
        MouseEventArgs me = new MouseEventArgs(System.Windows.Forms.MouseButtons.Left, 1, pt.X, pt.Y, 0);
        switch (m.Msg)
        {
            case Win32.WM_POINTERDOWN:
                    Console.WriteLine("TOCOU" + pt);
                    (Parent as Jogo).Form1_MouseDown((this as object), me);
                break;

            case Win32.WM_POINTERUP:
                    Console.WriteLine("LEVANTOU");
                    (Parent as Jogo).Form1_MouseUp((this as object), me);
                break;

            case Win32.WM_POINTERUPDATE:
                    //Console.WriteLine("UPDATE");
                    (Parent as Jogo).Form1_MouseMove((this as object), me);
                break;
        }
    }

I used the use of a class "Win32.cs" that can be downloaded here:

link

I hope it's useful;)

    
31.05.2014 / 17:45