Пример #1
0
        static internal OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt)
        {
            HIPoint point;

            unsafe
            {
                HIPoint *parm   = &point;
                OSStatus result = API.GetEventParameter(inEvent,
                                                        EventParamName.WindowMouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
                                                        (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero,
                                                        (IntPtr)parm);
                pt = point;

                return(result);
            }
        }
 internal static extern CGDisplayErr CGDisplayMoveCursorToPoint(IntPtr display, HIPoint point);
Пример #3
0
 internal static extern CGError WarpMouseCursorPosition(HIPoint newCursorPosition);
Пример #4
0
 internal static CGError WarpMouseCursorPosition(HIPoint newCursorPosition);
Пример #5
0
        OSStatus ProcessMouseEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData)
        {
            MacOSMouseButton button;
            HIPoint pt = new HIPoint();
            HIPoint screenLoc =  new HIPoint();

            OSStatus err = API.GetEventMouseLocation(inEvent, out screenLoc);

            if (this.windowState == WindowState.Fullscreen)
            {
                pt = screenLoc;
            }
            else
            {
                err = API.GetEventWindowMouseLocation(inEvent, out pt);
            }

            if (err != OSStatus.NoError)
            {
                // this error comes up from the application event handler.
                if (err != OSStatus.EventParameterNotFound)
                {
                    throw new MacOSException(err);
                }
            }

            Point mousePosInClient = new Point((int)pt.X, (int)pt.Y);
            if (this.windowState != WindowState.Fullscreen)
            {
                mousePosInClient.Y -= mTitlebarHeight;
            }

            // check for enter/leave events
            IntPtr thisEventWindow;
            API.GetEventWindowRef(inEvent, out thisEventWindow);
            CheckEnterLeaveEvents(thisEventWindow, mousePosInClient);

            switch ((MouseEventKind)evt.EventKind)
            {
                case MouseEventKind.MouseDown:
                    button = API.GetEventMouseButton(inEvent);

                    switch (button)
                    {
                        case MacOSMouseButton.Primary:
                            mouse[MouseButton.Left] = true;
                            break;

                        case MacOSMouseButton.Secondary:
                            mouse[MouseButton.Right] = true;
                            break;

                        case MacOSMouseButton.Tertiary:
                            mouse[MouseButton.Middle] = true;
                            break;
                    }
                    return OSStatus.NoError;

                case MouseEventKind.MouseUp:
                    button = API.GetEventMouseButton(inEvent);

                    switch (button)
                    {
                        case MacOSMouseButton.Primary:
                            mouse[MouseButton.Left] = false;
                            break;

                        case MacOSMouseButton.Secondary:
                            mouse[MouseButton.Right] = false;
                            break;

                        case MacOSMouseButton.Tertiary:
                            mouse[MouseButton.Middle] = false;
                            break;
                    }
                    button = API.GetEventMouseButton(inEvent);
                    return OSStatus.NoError;

                case MouseEventKind.WheelMoved:

                    int delta = API.GetEventMouseWheelDelta(inEvent) / 3;
                    mouse.Wheel += delta;
                    return OSStatus.NoError;

                case MouseEventKind.MouseMoved:
                case MouseEventKind.MouseDragged:

                    //Debug.Print("Mouse Location: {0}, {1}", pt.X, pt.Y);

                    if (windowState == WindowState.Fullscreen) {
                        if (mousePosInClient.X != mouse.X || mousePosInClient.Y != mouse.Y) {
                            mouse.Position = mousePosInClient;
                        }
                    } else {
                        // ignore clicks in the title bar
                        if (pt.Y < 0)
                            return OSStatus.EventNotHandled;

                        if (mousePosInClient.X != mouse.X || mousePosInClient.Y != mouse.Y) {
                            mouse.Position = mousePosInClient;
                        }
                    }
                    return OSStatus.EventNotHandled;

                default:
                    Debug.Print("{0}", evt);
                    return OSStatus.EventNotHandled;
            }
        }
Пример #6
0
 private HIPoint ConfineMouseToWindow(IntPtr window, HIPoint client)
 {
   if ((double) client.X < 0.0)
     client.X = 0.0f;
   if ((double) client.X >= (double) this.Width)
     client.X = (float) (this.Width - 1);
   if ((double) client.Y < 0.0)
     client.Y = 0.0f;
   if ((double) client.Y >= (double) this.Height)
     client.Y = (float) (this.Height - 1);
   return client;
 }
Пример #7
0
 protected OSStatus ProcessMouseEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData)
 {
   HIPoint pt1 = new HIPoint();
   HIPoint pt2 = new HIPoint();
   IntPtr windowRef;
   int num = (int) API.GetEventWindowRef(inEvent, out windowRef);
   OSStatus errorCode = API.GetEventMouseLocation(inEvent, out pt2);
   if (this.windowState == WindowState.Fullscreen)
     pt1 = pt2;
   else if (this.CursorVisible)
   {
     errorCode = API.GetEventWindowMouseLocation(inEvent, out pt1);
     pt1.Y -= (float) this.mTitlebarHeight;
   }
   else
   {
     errorCode = API.GetEventMouseDelta(inEvent, out pt1);
     pt1.X += this.mouse_rel_x;
     pt1.Y += this.mouse_rel_y;
     pt1 = this.ConfineMouseToWindow(windowRef, pt1);
     this.ResetMouseToWindowCenter();
     this.mouse_rel_x = pt1.X;
     this.mouse_rel_y = pt1.Y;
   }
   if (errorCode != OSStatus.NoError && errorCode != OSStatus.EventParameterNotFound)
     throw new MacOSException(errorCode);
   Point pt3 = new Point((int) pt1.X, (int) pt1.Y);
   this.CheckEnterLeaveEvents(windowRef, pt3);
   switch (evt.MouseEventKind)
   {
     case MouseEventKind.MouseDown:
     case MouseEventKind.MouseUp:
       OpenTK.Platform.MacOS.Carbon.MouseButton eventMouseButton = API.GetEventMouseButton(inEvent);
       bool flag = evt.MouseEventKind == MouseEventKind.MouseDown;
       switch (eventMouseButton)
       {
         case OpenTK.Platform.MacOS.Carbon.MouseButton.Primary:
           this.InputDriver.Mouse[0][OpenTK.Input.MouseButton.Left] = flag;
           break;
         case OpenTK.Platform.MacOS.Carbon.MouseButton.Secondary:
           this.InputDriver.Mouse[0][OpenTK.Input.MouseButton.Right] = flag;
           break;
         case OpenTK.Platform.MacOS.Carbon.MouseButton.Tertiary:
           this.InputDriver.Mouse[0][OpenTK.Input.MouseButton.Middle] = flag;
           break;
       }
       return OSStatus.NoError;
     case MouseEventKind.MouseMoved:
     case MouseEventKind.MouseDragged:
       if (this.windowState == WindowState.Fullscreen)
       {
         if (pt3.X != this.InputDriver.Mouse[0].X || pt3.Y != this.InputDriver.Mouse[0].Y)
           this.InputDriver.Mouse[0].Position = pt3;
       }
       else
       {
         if ((double) pt1.Y < 0.0 || pt3.X == this.InputDriver.Mouse[0].X && pt3.Y == this.InputDriver.Mouse[0].Y)
           return OSStatus.EventNotHandled;
         this.InputDriver.Mouse[0].Position = pt3;
       }
       return OSStatus.EventNotHandled;
     case MouseEventKind.WheelMoved:
       this.InputDriver.Mouse[0].WheelPrecise += (float) API.GetEventMouseWheelDelta(inEvent);
       return OSStatus.NoError;
     default:
       return OSStatus.EventNotHandled;
   }
 }
Пример #8
0
 internal static unsafe OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt)
 {
     HIPoint hiPoint;
       HIPoint* hiPointPtr = &hiPoint;
       OSStatus eventParameter = API.GetEventParameter(inEvent, EventParamName.WindowMouseLocation, EventParamType.typeHIPoint, IntPtr.Zero, (uint) Marshal.SizeOf(typeof (HIPoint)), IntPtr.Zero, (IntPtr) ((void*) hiPointPtr));
       pt = hiPoint;
       return eventParameter;
 }
Пример #9
0
        internal static OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt)
        {
            HIPoint point;

            unsafe
            {
                HIPoint* parm = &point;

                OSStatus result = API.GetEventParameter(inEvent,
                        EventParamName.WindowMouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
                        (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero,
                        (IntPtr)parm);

                pt = point;

                return result;
            }
        }
Пример #10
0
 public static unsafe extern IntPtr HIGetMousePosition( HICoordinateSpace space, IntPtr obj, ref HIPoint point );
Пример #11
0
        public static unsafe OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt)
        {
            HIPoint point;
            OSStatus result = API.GetEventParameter(inEvent,
                                                    EventParamName.WindowMouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
                                                    Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero, (IntPtr)(void*)&point);

            pt = point;
            return result;
        }
Пример #12
0
 public unsafe static extern IntPtr HIGetMousePosition(HICoordinateSpace space, IntPtr obj, ref HIPoint point);
 internal static extern CGDisplayErr CGDisplayMoveCursorToPoint(IntPtr display, HIPoint point);