public override void OnTouchStart(Game game_, TouchEventArgs e)
 {
     MouseEventArgs args = new MouseEventArgs();
     args.SetX(e.GetX());
     args.SetY(e.GetY());
     OnMouseDown(game_, args);
     e.SetHandled(args.GetHandled());
 }
Example #2
0
    void UpdateMousePosition()
    {
        current = Mouse.GetState();
        if (!window.Focused)
        {
            return;
        }
        if (current != previous)
        {
            // Mouse state has changed
            int xdelta = current.X - previous.X;
            int ydelta = current.Y - previous.Y;
            foreach (MouseEventHandler h in mouseEventHandlers)
            {
                MouseEventArgs args = new MouseEventArgs();
                args.SetX(lastX);
                args.SetY(lastY);
                args.SetMovementX(xdelta);
                args.SetMovementY(ydelta);
                args.SetEmulated(true);
                h.OnMouseMove(args);
            }
        }
        previous = current;
        if (mousePointerLocked)
        {
            /*
             * Windows: OK
             * Cursor hides properly
             * Cursor is trapped inside window
             * Centering works
             *
             * Linux: Needs workaround
             * Cursor hides properly
             * Cursor is trapped inside window
             * Centering broken
             *
             * Mac OS X: OK
             * Cursor hides properly (although visible when doing Skype screencast)
             * Centering works
             * Opening "mission control" by gesture does not free cursor
             */

            int centerx = window.Bounds.Left + (window.Bounds.Width / 2);
            int centery = window.Bounds.Top + (window.Bounds.Height / 2);

            // Setting cursor position this way works on Windows and Mac
            Mouse.SetPosition(centerx, centery);
        }
    }
Example #3
0
 void Mouse_Move(object sender, MouseMoveEventArgs e)
 {
     lastX = e.X;
     lastY = e.Y;
     if (TouchTest)
     {
         foreach (TouchEventHandler h in touchEventHandlers)
         {
             TouchEventArgs args = new TouchEventArgs();
             args.SetX(e.X);
             args.SetY(e.Y);
             args.SetId(0);
             h.OnTouchMove(args);
         }
     }
     else
     {
         foreach (MouseEventHandler h in mouseEventHandlers)
         {
             MouseEventArgs args = new MouseEventArgs();
             args.SetX(e.X);
             args.SetY(e.Y);
             args.SetMovementX(e.XDelta);
             args.SetMovementY(e.YDelta);
             args.SetEmulated(false);
             h.OnMouseMove(args);
         }
     }
 }
Example #4
0
 void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (TouchTest)
     {
         foreach (TouchEventHandler h in touchEventHandlers)
         {
             TouchEventArgs args = new TouchEventArgs();
             args.SetX(e.X);
             args.SetY(e.Y);
             args.SetId(0);
             h.OnTouchEnd(args);
         }
     }
     else
     {
         foreach (MouseEventHandler h in mouseEventHandlers)
         {
             MouseEventArgs args = new MouseEventArgs();
             args.SetX(e.X);
             args.SetY(e.Y);
             args.SetButton((int)e.Button);
             h.OnMouseUp(args);
         }
     }
 }
Example #5
0
    void window_RenderFrame(object sender, OpenTK.FrameEventArgs e)
    {
        UpdateMousePositionArgs a = new UpdateMousePositionArgs();
        UpdateMousePosition(a);
        if (!TouchTest)
        {
            foreach (MouseEventHandler h in mouseEventHandlers)
            {
                MouseEventArgs args2 = new MouseEventArgs();
                args2.SetX(a.mouseCurrentX);
                args2.SetY(a.mouseCurrentY);
                args2.SetMovementX((int)a.mouseDeltaX);
                args2.SetMovementY((int)a.mouseDeltaY);
                h.OnMouseMove(args2);
            }
        }

        foreach (NewFrameHandler h in newFrameHandlers)
        {
            NewFrameEventArgs args = new NewFrameEventArgs();
            args.SetDt((float)e.Time);
            h.OnNewFrame(args);
        }
        window.SwapBuffers();
    }
Example #6
0
 void Mouse_Move(object sender, MouseMoveEventArgs e)
 {
     if (TouchTest)
     {
         foreach (TouchEventHandler h in touchEventHandlers)
         {
             TouchEventArgs args = new TouchEventArgs();
             args.SetX(e.X);
             args.SetY(e.Y);
             args.SetId(0);
             h.OnTouchMove(args);
         }
     }
     else
     {
         foreach (MouseEventHandler h in mouseEventHandlers)
         {
             MouseEventArgs args = new MouseEventArgs();
             args.SetX(e.X);
             args.SetY(e.Y);
             h.OnMouseMove(args);
         }
     }
 }