public RawGenericInputReport(PresentationSource inputSource,
                 GenericEvent genericEvent, UIElement destTarget)
     : base(inputSource, genericEvent.Time)
 {
     InternalEvent = genericEvent;
     Target = destTarget;
 }
Exemplo n.º 2
0
        private static void GetEvent(uint data1, uint data2, DateTime time, ref EventInfo eventInfo, ref BaseEvent ev)
        {
            byte category = (byte)((data1 >> 8) & 0xFF);

            eventInfo = GetEventInfo((EventCategory)category);
            if (eventInfo.EventProcessor != null)
            {
                ev = eventInfo.EventProcessor.ProcessEvent(data1, data2, time);
            }
            else
            {
                GenericEvent genericEvent = new GenericEvent();
                genericEvent.Y             = (int)(data2 & 0xFFFF);
                genericEvent.X             = (int)((data2 >> 16) & 0xFFFF);
                genericEvent.Time          = time;
                genericEvent.EventMessage  = (byte)(data1 & 0xFF);
                genericEvent.EventCategory = category;
                genericEvent.EventData     = (data1 >> 16) & 0xFFFF;

                ev = genericEvent;
            }
        }
Exemplo n.º 3
0
        public bool OnEvent(BaseEvent ev)
        {
            InputReport ir  = null;
            InputDevice dev = null;

            /// Process known events, otherwise forward as generic to MainWindow.
            ///

            TouchEvent touchEvent = ev as TouchEvent;

            if (touchEvent != null)
            {
                Microsoft.SPOT.Presentation.UIElement targetWindow = TouchCapture.Captured;

                ///
                ///  Make sure the current event's coordinates are contained in the current
                ///  stylus/touch window, if not then search for the appropriate window
                ///
                if (targetWindow != null && touchEvent.EventMessage == (byte)TouchMessages.Down)
                {
                    int x = 0, y = 0, w, h;
                    int xSrc = touchEvent.Touches[0].X;
                    int ySrc = touchEvent.Touches[0].Y;

                    targetWindow.PointToScreen(ref x, ref y);
                    targetWindow.GetRenderSize(out w, out h);

                    if (!(x <= xSrc && xSrc <= (x + w) &&
                          y <= ySrc && ySrc <= (y + h)))
                    {
                        // only look for different target window if the touch point is inside
                        // the system metrics, otherwise, it may be a touch calibration point
                        // which is translated in the application layer.
                        if (xSrc <= SystemMetrics.ScreenWidth &&
                            ySrc <= SystemMetrics.ScreenHeight)
                        {
                            targetWindow = null;
                        }
                    }
                }

                if (targetWindow == null)
                {
                    //If we can enforce that the first event in the array is always the primary touch, we don't have to
                    //search.
                    targetWindow = WindowManager.Instance.GetPointerTarget(touchEvent.Touches[0].X, touchEvent.Touches[0].Y);
                }

                if (targetWindow != null)
                {
                    _inputManager.TouchDevice.SetTarget(targetWindow);
                }
                else
                {
                    _inputManager.TouchDevice.SetTarget(MainWindow);
                }

                ir =
                    new RawTouchInputReport(
                        null,
                        touchEvent.Time,
                        touchEvent.EventMessage,
                        touchEvent.Touches
                        );

                dev = _inputManager._touchDevice;
            }
            else if (ev is GenericEvent)
            {
                GenericEvent genericEvent = (GenericEvent)ev;

                Microsoft.SPOT.Presentation.UIElement targetWindow = TouchCapture.Captured;

                if (targetWindow == null)
                {
                    targetWindow = WindowManager.Instance.GetPointerTarget(genericEvent.X, genericEvent.Y);
                }

                if (targetWindow != null)
                {
                    _inputManager.GenericDevice.SetTarget(targetWindow);
                }
                else
                {
                    _inputManager.GenericDevice.SetTarget(MainWindow);
                }

                ir = new RawGenericInputReport(
                    null,
                    genericEvent
                    );

                dev = _inputManager._genericDevice;
            }
            else
            {
                /// Unkown event.
            }

            this.Dispatcher.BeginInvoke(_reportInputMethod, new InputReportArgs(dev, ir));

            return(true);
        }
 /// <summary>
 ///     Constructs an instance of the RawKeyboardInputReport class.
 /// </summary>
 /// <param name="inputSource">
 ///     source of the input
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 public RawGenericInputReport(PresentationSource inputSource, GenericEvent genericEvent)
     : base(inputSource, genericEvent.Time)
 {
     InternalEvent = genericEvent;
     Target = null;
 }
Exemplo n.º 5
0
        private static void GetEvent(uint data1, uint data2, DateTime time, ref EventInfo eventInfo, ref BaseEvent ev)
        {
            byte category = (byte)((data1 >> 8) & 0xFF);

            eventInfo = GetEventInfo((EventCategory)category);
            if (eventInfo.EventProcessor != null)
            {
                ev = eventInfo.EventProcessor.ProcessEvent(data1, data2, time);
            }
            else
            {
                GenericEvent genericEvent = new GenericEvent();
                genericEvent.Y = (int)(data2 & 0xFFFF);
                genericEvent.X = (int)((data2 >> 16) & 0xFFFF);
                genericEvent.Time = time;
                genericEvent.EventMessage = (byte)(data1 & 0xFF);
                genericEvent.EventCategory = category;
                genericEvent.EventData = (data1 >> 16) & 0xFFFF;

                ev = genericEvent;
            }
        }
Exemplo n.º 6
0
 public GenericEventArgs(InputDevice inputDevice, GenericEvent genericEvent)
     : base(inputDevice, genericEvent.Time)
 {
     InternalEvent = genericEvent;
 }