private void InvokeRecognitionEvent(GestureEventType eventType, InteractionSourceKind source, Ray headRay)
        {
            if (eventType != GestureEventType.RecognitionEnded)
            {
                if (eventType != GestureEventType.RecognitionStarted)
                {
                    throw new ArgumentException("InvokeRecognitionEvent: Invalid GestureEventType");
                }
            }
            else
            {
                RecognitionEndedEventDelegate recognitionEndedEvent = this.RecognitionEndedEvent;
                if (recognitionEndedEvent != null)
                {
                    recognitionEndedEvent(source, headRay);
                }
                return;
            }
            RecognitionStartedEventDelegate recognitionStartedEvent = this.RecognitionStartedEvent;

            if (recognitionStartedEvent != null)
            {
                recognitionStartedEvent(source, headRay);
            }
        }
Exemplo n.º 2
0
        internal static void SendMouseClickEvent(GestureEventType mouseEvent)
        {
            var mouse = new MOUSEINPUT();

            switch (mouseEvent)
            {
            case GestureEventType.MOUSE_LEFT_CLICK:
                mouse.dwFlags = (uint)MouseFlag.LEFTDOWN;
                SendMouseInput(mouse);
                mouse.dwFlags = (uint)MouseFlag.LEFTUP;
                SendMouseInput(mouse);
                break;

            case GestureEventType.MOUSE_MIDDLE_CLICK:
                mouse.dwFlags = (uint)MouseFlag.MIDDLEDOWN;
                SendMouseInput(mouse);
                mouse.dwFlags = (uint)MouseFlag.MIDDLEUP;
                SendMouseInput(mouse);
                break;

            case GestureEventType.MOUSE_RIGHT_CLICK:
                mouse.dwFlags = (uint)MouseFlag.RIGHTDOWN;
                SendMouseInput(mouse);
                mouse.dwFlags = (uint)MouseFlag.RIGHTUP;
                SendMouseInput(mouse);
                break;
            }
        }
Exemplo n.º 3
0
 private void Awake()
 {
     TouchManager = new TouchManager(2);
     TouchManager.RegisterGestureListener(this);
     Input.simulateMouseWithTouches = true;
     GestureType = GestureEventType.GESTURE_UNKNOWN;
 }
Exemplo n.º 4
0
 public BaseGestureEvent()
 {
     mEventX         = mEventY = 0;
     mTouchCount     = 1;
     mEventType      = GestureEventType.GESTURE_UNKNOWN;
     mFloatParameter = 0.0f;
     mIntParameter   = 0;
 }
Exemplo n.º 5
0
 public BaseGestureEvent(int x, int y, long time, int touchCount)
 {
     mEventX         = x;
     mEventY         = y;
     mEventTime      = time;
     mTouchCount     = touchCount;
     mEventType      = GestureEventType.GESTURE_UNKNOWN;
     mFloatParameter = 0.0f;
     mIntParameter   = 0;
 }
Exemplo n.º 6
0
        public string MakeKeyboardCode(GestureEventType gestureEventType)
        {
            var result = "";

            switch (gestureEventType)
            {
            case GestureEventType.NONE:
                break;

            case GestureEventType.SHIFT:
                result += "+"; break;

            case GestureEventType.CTRL:
                result += "^"; break;

            case GestureEventType.ALT:
                result += "%"; break;

            case GestureEventType.a:
            case GestureEventType.b:
            case GestureEventType.c:
            case GestureEventType.d:
            case GestureEventType.e:
            case GestureEventType.f:
            case GestureEventType.g:
            case GestureEventType.h:
            case GestureEventType.i:
            case GestureEventType.j:
            case GestureEventType.k:
            case GestureEventType.l:
            case GestureEventType.m:
            case GestureEventType.n:
            case GestureEventType.o:
            case GestureEventType.p:
            case GestureEventType.q:
            case GestureEventType.r:
            case GestureEventType.s:
            case GestureEventType.t:
            case GestureEventType.u:
            case GestureEventType.v:
            case GestureEventType.w:
            case GestureEventType.x:
            case GestureEventType.y:
            case GestureEventType.z:
                result += gestureEventType; break;

            default:
                result += "{" + gestureEventType + "}"; break;
            }

            return(result);
        }
Exemplo n.º 7
0
        internal static void AddMouseRollEvent(GestureEventType mouseEvent, double percentage, ref MOUSEINPUT mouse)
        {
            var velocity       = 0.15;
            var sign           = 1;
            var middleDistance = (percentage - 0.5);

            if (middleDistance < 0)
            {
                sign = -1;
            }
            var middleDistanceSquared = middleDistance * middleDistance * sign;

            switch (mouseEvent)
            {
            case GestureEventType.MOUSE_X_ABSOLUTE:
                var absoluteX = Math.Min((int)(percentage * 65535.0), 65535);
                mouse.dx       = absoluteX;
                mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
                break;

            case GestureEventType.MOUSE_Y_ABSOLUTE:
                var absoluteY = Math.Min((int)(percentage * 65535.0), 65535);
                mouse.dy       = absoluteY;
                mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
                break;

            case GestureEventType.MOUSE_WHEEL:
                // wheel data can be negative or positive
                // on this implementation it varies from -100 to 100
                var wheelMotion = (int)((percentage * 2 - 1.0) * 100);
                mouse.mouseData = (uint)wheelMotion;
                mouse.dwFlags  |= (uint)MouseFlag.WHEEL;
                break;

            case GestureEventType.MOUSE_X_MOVE:
                // middleDistance * middleDistance guarantees a stable behavior around the middle
                var deltaX = (middleDistanceSquared * 65535.0) * velocity;
                mouse.dx       = Math.Max(0, Math.Min(65535, (int)(mouse.dx + deltaX)));
                mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
                break;

            case GestureEventType.MOUSE_Y_MOVE:
                // middleDistance * middleDistance guarantees a stable behavior around the middle
                var deltaY = (middleDistanceSquared * 65535.0) * velocity;
                mouse.dy       = Math.Max(0, Math.Min(65535, (int)(mouse.dy + deltaY)));
                mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
                break;
            }
        }
        private void InvokeNavigationEvent(GestureEventType eventType, InteractionSourceKind source, Vector3 relativePosition, Ray headRay)
        {
            switch (eventType)
            {
            case GestureEventType.NavigationCanceled:
            {
                NavigationCanceledEventDelegate navigationCanceledEvent = this.NavigationCanceledEvent;
                if (navigationCanceledEvent != null)
                {
                    navigationCanceledEvent(source, relativePosition, headRay);
                }
                break;
            }

            case GestureEventType.NavigationCompleted:
            {
                NavigationCompletedEventDelegate navigationCompletedEvent = this.NavigationCompletedEvent;
                if (navigationCompletedEvent != null)
                {
                    navigationCompletedEvent(source, relativePosition, headRay);
                }
                break;
            }

            case GestureEventType.NavigationStarted:
            {
                NavigationStartedEventDelegate navigationStartedEvent = this.NavigationStartedEvent;
                if (navigationStartedEvent != null)
                {
                    navigationStartedEvent(source, relativePosition, headRay);
                }
                break;
            }

            case GestureEventType.NavigationUpdated:
            {
                NavigationUpdatedEventDelegate navigationUpdatedEvent = this.NavigationUpdatedEvent;
                if (navigationUpdatedEvent != null)
                {
                    navigationUpdatedEvent(source, relativePosition, headRay);
                }
                break;
            }

            default:
                throw new ArgumentException("InvokeNavigationEvent: Invalid GestureEventType");
            }
        }
Exemplo n.º 9
0
        public string MakeKeyboardCode(GestureEventType gestureEventType)
        {
            var result = "";

            switch (gestureEventType)
            {
                case GestureEventType.NONE:
                    break;
                case GestureEventType.SHIFT:
                    result += "+"; break;
                case GestureEventType.CTRL:
                    result += "^"; break;
                case GestureEventType.ALT:
                    result += "%"; break;
                case GestureEventType.a:
                case GestureEventType.b:
                case GestureEventType.c:
                case GestureEventType.d:
                case GestureEventType.e:
                case GestureEventType.f:
                case GestureEventType.g:
                case GestureEventType.h:
                case GestureEventType.i:
                case GestureEventType.j:
                case GestureEventType.k:
                case GestureEventType.l:
                case GestureEventType.m:
                case GestureEventType.n:
                case GestureEventType.o:
                case GestureEventType.p:
                case GestureEventType.q:
                case GestureEventType.r:
                case GestureEventType.s:
                case GestureEventType.t:
                case GestureEventType.u:
                case GestureEventType.v:
                case GestureEventType.w:
                case GestureEventType.x:
                case GestureEventType.y:
                case GestureEventType.z:
                    result += gestureEventType; break;
                default:
                    result += "{" + gestureEventType + "}"; break;
            }

            return result;
        }
Exemplo n.º 10
0
        private void InvokeHoldEvent(GestureEventType eventType, InteractionSourceKind source, Ray headRay)
        {
            switch (eventType)
            {
            case GestureEventType.HoldCanceled:
            {
                HoldCanceledEventDelegate holdCanceledEvent = this.HoldCanceledEvent;
                if (holdCanceledEvent != null)
                {
                    holdCanceledEvent(source, headRay);
                }
                break;
            }

            case GestureEventType.HoldCompleted:
            {
                HoldCompletedEventDelegate holdCompletedEvent = this.HoldCompletedEvent;
                if (holdCompletedEvent != null)
                {
                    holdCompletedEvent(source, headRay);
                }
                break;
            }

            case GestureEventType.HoldStarted:
            {
                HoldStartedEventDelegate holdStartedEvent = this.HoldStartedEvent;
                if (holdStartedEvent != null)
                {
                    holdStartedEvent(source, headRay);
                }
                break;
            }

            default:
                throw new ArgumentException("InvokeHoldEvent: Invalid GestureEventType");
            }
        }
Exemplo n.º 11
0
 private void InvokeHoldEvent(GestureEventType eventType, InteractionSourceKind source, Ray headRay)
 {
     switch (eventType)
     {
         case GestureEventType.HoldCanceled:
         {
             HoldCanceledEventDelegate holdCanceledEvent = this.HoldCanceledEvent;
             if (holdCanceledEvent != null)
             {
                 holdCanceledEvent(source, headRay);
             }
             break;
         }
         case GestureEventType.HoldCompleted:
         {
             HoldCompletedEventDelegate holdCompletedEvent = this.HoldCompletedEvent;
             if (holdCompletedEvent != null)
             {
                 holdCompletedEvent(source, headRay);
             }
             break;
         }
         case GestureEventType.HoldStarted:
         {
             HoldStartedEventDelegate holdStartedEvent = this.HoldStartedEvent;
             if (holdStartedEvent != null)
             {
                 holdStartedEvent(source, headRay);
             }
             break;
         }
         default:
             throw new ArgumentException("InvokeHoldEvent: Invalid GestureEventType");
     }
 }
Exemplo n.º 12
0
 private void InvokeNavigationEvent(GestureEventType eventType, InteractionSourceKind source, Vector3 relativePosition, Ray headRay)
 {
     switch (eventType)
     {
         case GestureEventType.NavigationCanceled:
         {
             NavigationCanceledEventDelegate navigationCanceledEvent = this.NavigationCanceledEvent;
             if (navigationCanceledEvent != null)
             {
                 navigationCanceledEvent(source, relativePosition, headRay);
             }
             break;
         }
         case GestureEventType.NavigationCompleted:
         {
             NavigationCompletedEventDelegate navigationCompletedEvent = this.NavigationCompletedEvent;
             if (navigationCompletedEvent != null)
             {
                 navigationCompletedEvent(source, relativePosition, headRay);
             }
             break;
         }
         case GestureEventType.NavigationStarted:
         {
             NavigationStartedEventDelegate navigationStartedEvent = this.NavigationStartedEvent;
             if (navigationStartedEvent != null)
             {
                 navigationStartedEvent(source, relativePosition, headRay);
             }
             break;
         }
         case GestureEventType.NavigationUpdated:
         {
             NavigationUpdatedEventDelegate navigationUpdatedEvent = this.NavigationUpdatedEvent;
             if (navigationUpdatedEvent != null)
             {
                 navigationUpdatedEvent(source, relativePosition, headRay);
             }
             break;
         }
         default:
             throw new ArgumentException("InvokeNavigationEvent: Invalid GestureEventType");
     }
 }
Exemplo n.º 13
0
 private void InvokeRecognitionEvent(GestureEventType eventType, InteractionSourceKind source, Ray headRay)
 {
     if (eventType != GestureEventType.RecognitionEnded)
     {
         if (eventType != GestureEventType.RecognitionStarted)
         {
             throw new ArgumentException("InvokeRecognitionEvent: Invalid GestureEventType");
         }
     }
     else
     {
         RecognitionEndedEventDelegate recognitionEndedEvent = this.RecognitionEndedEvent;
         if (recognitionEndedEvent != null)
         {
             recognitionEndedEvent(source, headRay);
         }
         return;
     }
     RecognitionStartedEventDelegate recognitionStartedEvent = this.RecognitionStartedEvent;
     if (recognitionStartedEvent != null)
     {
         recognitionStartedEvent(source, headRay);
     }
 }
Exemplo n.º 14
0
 internal static void AddMouseRollEvent(GestureEventType mouseEvent, double percentage, ref MOUSEINPUT mouse)
 {
     var velocity = 0.05;
     var sign = 1;
     var middleDistance = (percentage - 0.5);
     if (middleDistance < 0) sign = -1;
     var middleDistanceSquared = middleDistance * middleDistance * sign;
     switch (mouseEvent)
     {
         case GestureEventType.MOUSE_X_ABSOLUTE:
             var absoluteX = Math.Min((int)(percentage * 65535.0), 65535);
             mouse.dx = absoluteX;
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
         case GestureEventType.MOUSE_Y_ABSOLUTE:
             var absoluteY = Math.Min((int)(percentage * 65535.0), 65535);
             mouse.dy = absoluteY;
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
         case GestureEventType.MOUSE_WHEEL:
             // wheel data can be negative or positive
             // on this implementation it varies from -100 to 100
             var wheelMotion = (int)((percentage * 2 - 1.0) * 100);
             mouse.mouseData = (uint)wheelMotion;
             mouse.dwFlags |= (uint)MouseFlag.WHEEL;
             break;
         case GestureEventType.MOUSE_X_MOVE:
             // middleDistance * middleDistance guarantees a stable behavior around the middle
             var deltaX = (middleDistanceSquared * 65535.0) * velocity;
             mouse.dx = Math.Max(0, Math.Min(65535, (int)(mouse.dx + deltaX)));
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
         case GestureEventType.MOUSE_Y_MOVE:
             // middleDistance * middleDistance guarantees a stable behavior around the middle
             var deltaY = (middleDistanceSquared * 65535.0) * velocity;
             mouse.dy = Math.Max(0, Math.Min(65535, (int)(mouse.dy + deltaY)));
             mouse.dwFlags |= (uint)MouseFlag.MOVE | (uint)MouseFlag.ABSOLUTE;
             break;
     }
 }
Exemplo n.º 15
0
        public void GestureEvent(BaseGestureEvent gestureEvent)
        {
            GestureType = gestureEvent.GetEventType();
            switch (gestureEvent.GetEventType())
            {
            case GestureEventType.GESTURE_TAP:
                Debug.Log("GESTURE_TAP");
                break;

            case GestureEventType.GESTURE_DOUBLE_CLICK:
                Debug.Log("GESTURE_DOUBLE_CLICK");
                break;

            case GestureEventType.GESTURE_LONG_TAP:
                Debug.Log("GESTURE_LONG_TAP");
                break;

            case GestureEventType.GESTURE_BEGIN_MOVE:
                Debug.Log("GESTURE_BEGIN_MOVE");
                break;

            case GestureEventType.GESTURE_MOVE:
                Debug.Log("GESTURE_MOVE");
                break;

            case GestureEventType.GESTURE_END_MOVE:
                Debug.Log("GESTURE_END_MOVE");
                break;

            case GestureEventType.GESTURE_DRAG:
                Debug.Log("GESTURE_DRAG");
                break;

            case GestureEventType.GESTURE_DRAG_MOVE:
                Debug.Log("GESTURE_DRAG_MOVE");
                break;

            case GestureEventType.GESTURE_DROP:
                Debug.Log("GESTURE_DROP");
                break;

            case GestureEventType.GESTURE_ARC:
                Debug.Log("GESTURE_ARC");
                break;

            case GestureEventType.GESTURE_PINCH:
                Debug.Log("GESTURE_PINCH");
                break;

            case GestureEventType.GESTURE_SWIPE:
                Debug.Log("GESTURE_SWIPE");
                break;

            case GestureEventType.GESTURE_ROTATE:
                Debug.Log("GESTURE_ROTATE");
                break;

            case GestureEventType.GESTURE_UNKNOWN:
                Debug.Log("GESTURE_UNKNOWN");
                break;

            default:
                Debug.Log("wrong GESTURE");
                break;
            }
        }
Exemplo n.º 16
0
 public GestureEvent(string part1String, string part2String, string trigger)
 {
     EventPart1 = (GestureEventType)Enum.Parse(typeof(GestureEventType), part1String);
     EventPart2 = (GestureEventType)Enum.Parse(typeof(GestureEventType), part2String);
     TriggerGestureName = trigger;
 }
Exemplo n.º 17
0
 public GestureEvent()
 {
     EventPart1 = GestureEventType.NONE;
     EventPart2 = GestureEventType.NONE;
     TriggerGestureName = "anything";
 }
Exemplo n.º 18
0
 internal static void SendMouseClickEvent(GestureEventType mouseEvent)
 {
     var mouse = new MOUSEINPUT();
     switch (mouseEvent)
     {
         case GestureEventType.MOUSE_LEFT_CLICK:
             mouse.dwFlags = (uint)MouseFlag.LEFTDOWN;
             SendMouseInput(mouse);
             mouse.dwFlags = (uint)MouseFlag.LEFTUP;
             SendMouseInput(mouse);
             break;
         case GestureEventType.MOUSE_MIDDLE_CLICK:
             mouse.dwFlags = (uint)MouseFlag.MIDDLEDOWN;
             SendMouseInput(mouse);
             mouse.dwFlags = (uint)MouseFlag.MIDDLEUP;
             SendMouseInput(mouse);
             break;
         case GestureEventType.MOUSE_RIGHT_CLICK:
             mouse.dwFlags = (uint)MouseFlag.RIGHTDOWN;
             SendMouseInput(mouse);
             mouse.dwFlags = (uint)MouseFlag.RIGHTUP;
             SendMouseInput(mouse);
             break;
     }
 }