Ejemplo n.º 1
0
        /// <summary>
        /// Coroutine that trigger Hold Event when one finger holded
        /// after given HoldDuration time in second
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        private IEnumerator FingerHold(Vector2 position)
        {
            yield return(new WaitForSeconds(holdDuration));

            GestureType = GestureTypes.Hold;
            OnHold?.Invoke(position);
        }
Ejemplo n.º 2
0
 public virtual bool ReceiveEvent(GestureTypes type)
 {
     Debug.Log("ReceiveEvent " + type.ToString());
     _currentType = type;
     Invoke("unBlockCurrentGesture", TimeBetween2Gestures);
     return(true);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Resets all of touch processes
 /// </summary>
 private void Reset()
 {
     raycastResult.Clear();
     startPositions = new Vector2[2];
     endPositions   = new Vector2[2];
     GestureType    = GestureTypes.Touch;
 }
 public override void LoadingGestureProgress(GestureTypes type, float percent)
 {
     if (_gameManager != null)
     {
         _gameManager.UpdateUILoadingGesture(type, percent);
     }
 }
Ejemplo n.º 5
0
        public void OnGesture(GestureTypes gestureType,
                              GameObject focusedGameObject)
        {
            AudioClip           audioClip           = null;
            GestureSoundHandler gestureSoundHandler = null;

            if (focusedGameObject != null)
            {
                gestureSoundHandler = focusedGameObject.GetComponent <GestureSoundHandler>();
            }

            if (gestureSoundHandler != null)
            {
                // Fetch the appropriate audio clip from the GestureSoundHandler's AudioClips array.
                audioClip = gestureSoundHandler.AudioClips[(int)gestureType];
            }

            if (audioClip != null)
            {
                // Move the audio source container to the location of the focused object so that
                // the gesture sound is properly spatialized with the focused object.
                audioSourceContainer.transform.position = focusedGameObject.transform.position;

                // Set the AudioSource clip field to the audioClip
                audioSource.clip = audioClip;

                // Play the AudioSource
                audioSource.Play();
            }
            else
            {
                // Stop the AudioSource
                audioSource.Stop();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Gesture event arguments.</param>
        private void OnGestureRecognized(object sender, GestureEventArgs e)
        {
            switch (e.GestureName)
            {
            case "JoinedHands":
                //KinectSwipeDetected = GestureTypes.JoinedHands;
                break;

            case "SwipeLeft":
                KinectGestureDetected = GestureTypes.RightSwipe;
                break;

            case "SwipeRight":
                KinectGestureDetected = GestureTypes.LeftSwipe;
                break;

            case "SwipeUp":
                //KinectSwipeDetected = GestureTypes.SwipeUp;
                break;

            default:
                break;
            }

            _clearTimer.Start();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Sets whether a gesture should be handled by the touchpad.
        /// </summary>
        /// <param name="gestureTypes">The gesture type to set.</param>
        /// <param name="enabled">True to enable gesture, false to disable.</param>
        public void SetGesture(GestureTypes gestureTypes, bool enabled)
        {
            _log.DebugFormat("SetGesture is {0} gestures: {1}", enabled ? "enabling" : "disabling", gestureTypes);

            // TODO: Fix this hacky workaround when Razer fixes their code
            var values =
                Enum.GetValues(gestureTypes.GetType()).Cast <Enum>().Where(gestureTypes.HasFlag).Cast <GestureTypes>();

            HRESULT result;

            foreach (var value in values)
            {
                result = NativeMethods.RzSBEnableGesture(value, enabled);
                if (HRESULT.RZSB_FAILED(result))
                {
                    throw new NativeCallException("RzSBEnableGesture", result);
                }
            }

            result = NativeMethods.RzSBGestureSetCallback(_gestureCallback);
            if (HRESULT.RZSB_FAILED(result))
            {
                throw new NativeCallException("RzSBGestureSetCallback", result);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Removes gesture if it's there.
 /// </summary>
 /// <param name="gesture"> Gesture to remove. </param>
 public void RemoveGesture(GestureTypes gesture)
 {
     if ((gesture & _trackedGestures) == gesture)
     {
         _trackedGestures ^= gesture;
         UpdateGestureStates(true);
     }
 }
Ejemplo n.º 9
0
        // Called once application started
        void Start()
        {
            // Always assume the gesture is touch
            GestureType = GestureTypes.Touch;

            // Initialize raycast result object
            raycastResult = new List <RaycastResult>();
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GestureEventArgs" /> class.
 /// </summary>
 /// <param name="gestureTypes">Type of gesture.</param>
 /// <param name="parameter">Contextual parameter associated with the gesture.</param>
 /// <param name="x">X position of gesture.</param>
 /// <param name="y">Y position of gesture.</param>
 /// <param name="z">Z position of gesture.</param>
 internal GestureEventArgs(GestureTypes gestureTypes, uint parameter, ushort x, ushort y, ushort z)
 {
     _gestureTypes = gestureTypes;
     _parameter    = parameter;
     _x            = x;
     _y            = y;
     _z            = z;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Adds gesture if it's not there already.
 /// </summary>
 /// <param name="gesture"> Gesture to add. </param>
 public void AddGesture(GestureTypes gesture)
 {
     if ((gesture & _trackedGestures) != gesture)
     {
         _trackedGestures |= gesture;
         UpdateGestureStates(true);
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Raises gesture event to subscribers.
        /// </summary>
        /// <param name="gestureTypes">Type of gesture.</param>
        /// <param name="parameter">Contextual parameter associated with gesture.</param>
        /// <param name="x">X position of gesture.</param>
        /// <param name="y">Y position of gesture.</param>
        /// <param name="z">Z position of gesture.</param>
        private void OnGesture(GestureTypes gestureTypes, uint parameter, ushort x, ushort y, ushort z)
        {
            var func = Gesture;

            if (func != null)
            {
                func(this, new GestureEventArgs(gestureTypes, parameter, x, y, z));
            }
        }
Ejemplo n.º 13
0
 public bool ReceiveEvent(GestureTypes type)
 {
     if (gameManager.IsReadyUI())
     {
         currentType = type;
         gameManager.UpdateUIBlockingGesture(type, TimeBetween2Gestures, UnBlockGesture);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 14
0
 public override bool ReceiveEvent(GestureTypes type)
 {
     if (_gameManager.IsReadyUI())
     {
         _currentType = type;
         _gameManager.UpdateUIBlockingGesture(type, TimeBetween2Gestures, unBlockGesture);
         _gameManager.NavigateMenu(type);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Initializes a new <see cref="GestureSample"/>.
 /// </summary>
 public GestureSample(
     GestureTypes gestureType,
     TimeSpan timestamp,
     Vector2 position1, Vector2 position2,
     Vector2 delta1, Vector2 delta2)
 {
     GestureType = gestureType;
     Timestamp   = timestamp;
     Position1   = position1;
     Position2   = position2;
     Delta1      = delta1;
     Delta2      = delta2;
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Create a wired-up recognizer for running the slideshow.
        /// </summary>
        /// <returns>The wired-up recognizer.</returns>
        private Recognizer CreateRecognizer()
        {
            // Instantiate a recognizer.
            var recognizer = new Recognizer();

            // Wire-up swipe right to manually advance picture.
            recognizer.SwipeRightDetected += (s, e) =>
            {
                KinectSwipeDetected = GestureTypes.RightSwipe;
            };

            // Wire-up swipe left to manually reverse picture.
            recognizer.SwipeLeftDetected += (s, e) =>
            {
                KinectSwipeDetected = GestureTypes.LeftSwipe;
            };

            return(recognizer);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Get the gestures enabled in an MLStaticGestureType array.
        /// </summary>
        /// <returns> The array of gestures being tracked.</returns>
        private MLStaticGestureType[] GetGestureTypes()
        {
            int[] enumValues = (int[])Enum.GetValues(typeof(GestureTypes));
            List <MLStaticGestureType> gestures = new List <MLStaticGestureType>();

            _currentGestures = 0;
            GestureTypes current;

            for (int i = 0; i < enumValues.Length; ++i)
            {
                current = (GestureTypes)enumValues[i];
                if ((_trackedGestures & current) == current)
                {
                    _currentGestures |= current;
                    gestures.Add((MLStaticGestureType)i);
                }
            }

            return(gestures.ToArray());
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Detects finger movement for +-X or +-Y direction
        /// </summary>
        /// <param name="swipeDelta"></param>
        private void DetectSwipe(Vector2 swipeDelta)
        {
            SwipeDirections SwipeDirection;

            // Check finger movement distance is much more then threshold
            if (swipeDelta.magnitude >= swipeThreshold)
            {
                // Assign gesture type to swipe to prevent touch event
                GestureType = GestureTypes.Swipe;

                // If movement on X axis, trigger right or left
                // else trigger up or bottom
                if (IsHorizontalSwipe(swipeDelta))
                {
                    SwipeDirection = swipeDelta.x < 0 ? SwipeDirections.Left : SwipeDirections.Right;
                }
                else
                {
                    SwipeDirection = swipeDelta.y < 0 ? SwipeDirections.Bottom : SwipeDirections.Up;
                }

                OnSwipe?.Invoke(SwipeDirection);
            }
        }
Ejemplo n.º 19
0
        void UnBlockGesture(GestureTypes type)
        {
            Gesture behavior = (Gesture)listActiveGestures [type];

            behavior.UnBlockGesture();
        }
Ejemplo n.º 20
0
 public void LoadingGestureProgress(GestureTypes type, float percent)
 {
     gameManager.UpdateUILoadingGesture(type, percent);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Disables forwarding of a gesture.
 /// </summary>
 /// <param name="gestureTypes">Gesture to disable.</param>
 public void DisableOSGesture(GestureTypes gestureTypes)
 {
     SetOSGesture(gestureTypes, false);
 }
Ejemplo n.º 22
0
    void LateUpdate()
    {
        if (Input.GetMouseButtonDown(0)){

            velocityXInit = Mathf.Abs(velocityX);
            velocityYInit = Mathf.Abs(velocityY);

            Debug.Log ("MouseDown");
            txtGesture.text = "MouseDown";
            gesture = GestureTypes.MouseDown;
            MouseDown();

        } else
        if (Input.GetMouseButton(0)){

            velocityX += xSpeed * Input.GetAxis("Mouse X") * 0.02f;
            velocityY += ySpeed * Input.GetAxis("Mouse Y") * 0.02f;

            if ((Mathf.Abs(velocityX) > velocityXInit + dragTreshold) || (Mathf.Abs(velocityY) > velocityYInit + dragTreshold)){

                    if (gesture == GestureTypes.MouseDown){
                        Debug.Log ("DragBegin");
                        txtGesture.text = "DragBegin";
                        gesture = GestureTypes.DragBegin;
                        DragBegin();
                    }else{
                        Debug.Log ("DragOn");
                        txtGesture.text = "DragOn";
                        gesture = GestureTypes.DragOn;
                        DragOn();
                    }
            }
        } else
        if (Input.GetMouseButtonUp(0)){

            velocityXInit = Mathf.Abs(velocityX);
            velocityYInit = Mathf.Abs(velocityY);

            if (gesture == GestureTypes.DragOn){
                    Debug.Log ("DragEnd");
                    txtGesture.text = "DragEnd";
                    gesture = GestureTypes.DragEnd;
                    DragEnd();
            }else{
                    Debug.Log ("MouseUp");
                    txtGesture.text = "MouseUp";
                    gesture = GestureTypes.MouseUp;
                    MouseUp();
            }

        }

            // On each lateUpdate during selection phase:

            // on clic:
        if (gameManager != GameManager.Zoom) {

            if((gesture == GestureTypes.MouseDown) || (gesture == GestureTypes.MouseUp)){
                rotation = Quaternion.Slerp(transform.rotation, toRotation, Time.deltaTime * smoothTime);

            }else{ // on drag:
                rotationYAxis += velocityX;
                rotationXAxis -= velocityY;
                rotationXAxis = ClampAngle(rotationXAxis, yMinLimit, yMaxLimit);

                toRotation = Quaternion.Euler(rotationXAxis, rotationYAxis, 0);
                rotation = toRotation;

                velocityX = Mathf.Lerp(velocityX, 0, Time.deltaTime * smoothTime);
                velocityY = Mathf.Lerp(velocityY, 0, Time.deltaTime * smoothTime);
            }

        }else{

            RaycastHit hit;

            if (Physics.Raycast(transform.position, transform.forward, out hit, 20)){

                distance = Mathf.Lerp(distance, hit.distance, Time.deltaTime * smoothTime /2);
                //txtZone.text= "Zoom " + distance.ToString();

                if (hit.distance > 5.0f){
                    blur = 0;
                }else if (hit.distance < 0.6f){
                    Application.LoadLevel(2);

                }else{
                    blur = Mathf.Abs(5-hit.distance) * 10;
                }

                txtZoom.text = blur.ToString();
                be.blurSize = blur;
            }

        }
        Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
        Vector3 position = rotation * negDistance + target.position;

        transform.rotation = rotation;
        transform.position = position;
    }
Ejemplo n.º 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Gesture event arguments.</param>
        private void OnGestureRecognized(object sender, GestureEventArgs e)
        {
            switch (e.GestureName)
            {
                case "JoinedHands":
                    //KinectSwipeDetected = GestureTypes.JoinedHands;
                    break;
                case "SwipeLeft":
                    KinectGestureDetected = GestureTypes.RightSwipe;
                    break;
                case "SwipeRight":
                    KinectGestureDetected = GestureTypes.LeftSwipe;
                    break;
                case "SwipeUp":
                    //KinectSwipeDetected = GestureTypes.SwipeUp;
                    break;
                default:
                    break;
            }

            _clearTimer.Start();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Handles the native gesture event sent from Razer SDK.
        /// </summary>
        /// <param name="gestureTypes">Type of gesture.</param>
        /// <param name="parameters">Parameters associated with gesture event.</param>
        /// <param name="x">X position.</param>
        /// <param name="y">Y position.</param>
        /// <param name="z">Z position.</param>
        /// <returns><see cref="HRESULT" /> object indicating success or failure.</returns>
        private HRESULT HandleTouchpadGesture(GestureTypes gestureTypes, uint parameters, ushort x, ushort y, ushort z)
        {
            OnGesture(gestureTypes, parameters, x, y, z);

            switch (gestureTypes)
            {
            case GestureTypes.Press:
                OnPress(parameters, x, y);
                break;

            case GestureTypes.Tap:
                OnTap(x, y);
                break;

            case GestureTypes.Flick:
            {
                var direction = (Direction)z;
                OnFlick(parameters, direction);
                break;
            }

            case GestureTypes.Zoom:
            {
                ZoomDirection direction;
                switch (parameters)
                {
                case 1:
                    direction = ZoomDirection.In;
                    break;

                case 2:
                    direction = ZoomDirection.Out;
                    break;

                default:
                    direction = ZoomDirection.Invalid;
                    break;
                }

                OnZoom(direction);
                break;
            }

            case GestureTypes.Rotate:
            {
                RotateDirection direction;
                switch (parameters)
                {
                case 1:
                    direction = RotateDirection.Clockwise;
                    break;

                case 2:
                    direction = RotateDirection.Counterclockwise;
                    break;

                default:
                    direction = RotateDirection.Invalid;
                    break;
                }

                OnRotate(direction);
                break;
            }

            case GestureTypes.Move:
                OnMove(x, y);
                break;

            case GestureTypes.Hold:
                OnHold(parameters, x, y, z);
                break;

            case GestureTypes.Release:
                OnRelease(parameters, x, y);
                break;

            case GestureTypes.Scroll:
                OnScroll(parameters, x, y, z);
                break;
            }

            return(HRESULT.RZSB_OK);
        }
Ejemplo n.º 25
0
 internal static extern HRESULT RzSBEnableGesture(
     [In] GestureTypes gestureTypes,
     [In][MarshalAs(UnmanagedType.U1)] bool enable);
Ejemplo n.º 26
0
        protected void unBlockGesture(GestureTypes type)
        {
            BehaviorHand behavior = (BehaviorHand)_listActiveGestures [type];

            behavior.UnBlockGesture();
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Enables a gesture to be forwarded to the host operating system.
 /// </summary>
 /// <param name="gestureTypes">Gesture to forward.</param>
 public void EnableOSGesture(GestureTypes gestureTypes)
 {
     SetOSGesture(gestureTypes, true);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// Clear text after some time
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void clearTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     kinectGestureDetected = GestureTypes.None;
     _clearTimer.Stop();
 }
Ejemplo n.º 29
0
 public CustomGesture(Frame frame)
 {
     currentFrame = frame;
     //immediately check to see if the frame contains a custom gesture
     GestureType = DetermineGesture();
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Clear text after some time
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void clearTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     kinectGestureDetected = GestureTypes.None;
     _clearTimer.Stop();
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Create a wired-up recognizer for running the slideshow.
        /// </summary>
        /// <returns>The wired-up recognizer.</returns>
        private Recognizer CreateRecognizer()
        {
            // Instantiate a recognizer.
            var recognizer = new Recognizer();
            // Wire-up swipe right to manually advance picture.
            recognizer.SwipeRightDetected += (s, e) =>
            {
                KinectSwipeDetected = GestureTypes.RightSwipe;
            };

            // Wire-up swipe left to manually reverse picture.
            recognizer.SwipeLeftDetected += (s, e) =>
            {
                KinectSwipeDetected = GestureTypes.LeftSwipe;
            };

            return recognizer;
        }
Ejemplo n.º 32
0
    // Use this for initialization
    void Start()
    {
        gesture = GestureTypes.None;
        gameManager = GameManager.Start;
        currentZone = Zones.none;

        ResetZonesColor();

        // init cam position
        toRotation = transform.rotation;
        rotation = toRotation;
        Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance);
        Vector3 position = rotation * negDistance + target.position;
        transform.rotation = rotation;
        transform.position = position;

        Vector3 angles = transform.eulerAngles;
        rotationYAxis = angles.y;
        rotationXAxis = angles.x;

        // Make the rigid body not change rotation
        if (GetComponent<Rigidbody>())
        {
            GetComponent<Rigidbody>().freezeRotation = true;
        }

        be = GetComponent<Camera>().GetComponent<Blur>();
        audio = GetComponent<AudioSource>();
    }
Ejemplo n.º 33
0
 public virtual void LoadingGestureProgress(GestureTypes type, float percent)
 {
 }