Пример #1
0
        /// <summary>
        /// Sends the events for controller visibility changes.
        /// </summary>
        private void SendControllerVisibilityEvents()
        {
            // Send event for new controllers that were added
            foreach (uint newController in newControllers)
            {
                InputSourceEventArgs args = new InputSourceEventArgs(this, newController);
                inputManager.RaiseSourceDetected(args.InputSource, args.SourceId);
            }

            // Send event for controllers that are no longer visible and remove them from our dictionary
            foreach (uint existingController in controllerIdToData.Keys)
            {
                if (!currentControllers.Contains(existingController))
                {
                    pendingControllerIdDeletes.Add(existingController);
                    InputSourceEventArgs args = new InputSourceEventArgs(this, existingController);
                    inputManager.RaiseSourceLost(args.InputSource, args.SourceId);
                }
            }

            // Remove pending controller IDs
            for (int i = 0; i < pendingControllerIdDeletes.Count; ++i)
            {
                controllerIdToData.Remove(pendingControllerIdDeletes[i]);
            }
            pendingControllerIdDeletes.Clear();
        }
        private void Update()
        {
            if (usingWiimote)// && !click_a)
            {
                Receive();
            }
            if (click_a)
            {
                // Manual implementation of a timeout--make sure a click isn't processed twice
                //if (waitCount < 10) { Debug.Log("No click: " + waitCount); click_a = false;  waitCount++; }
                //else
                //{
                click_a   = false;
                waitCount = 0;
                SourceClickEventArgs args = new SourceClickEventArgs(this, 0, 1); // manual tap count of 1

                RaiseSourceClickedEvent(args);
                //}
            }
            else if (press_b && send_b)
            {
                InputSourceEventArgs args = new InputSourceEventArgs(this, 0);
                RaiseSourceDownEvent(args);
                send_b = false;
            }
            else if (release_b)
            {
                release_b = false;
                InputSourceEventArgs args = new InputSourceEventArgs(this, 0);
                RaiseSourceUpEvent(args);
            }
        }
        /// <summary>
        /// Sends the events for source visibility changes.
        /// </summary>
        private void SendSourceVisibilityEvents()
        {
            // Send event for new sources that were added
            foreach (uint newSource in newSources)
            {
                InputSourceEventArgs args = new InputSourceEventArgs(this, newSource);
                RaiseSourceDetectedEvent(args);
            }

            // Send event for sources that are no longer visible and remove them from our dictionary
            foreach (uint existingSource in sourceIdToData.Keys)
            {
                if (!currentSources.Contains(existingSource))
                {
                    pendingSourceIdDeletes.Add(existingSource);
                    InputSourceEventArgs args = new InputSourceEventArgs(this, existingSource);
                    RaiseSourceLostEvent(args);
                }
            }

            // Remove pending source IDs
            for (int i = 0; i < pendingSourceIdDeletes.Count; ++i)
            {
                sourceIdToData.Remove(pendingSourceIdDeletes[i]);
            }
            pendingSourceIdDeletes.Clear();
        }
Пример #4
0
        public void RaiseSourceDetected(IInputSource source, uint sourceId)
        {
            // Manage list of detected sources
            bool alreadyDetected = false;

            InputSourceEventArgs args = new InputSourceEventArgs(source, sourceId);

            for (int iDetected = 0; iDetected < detectedInputSources.Count; iDetected++)
            {
                if (detectedInputSources[iDetected].Matches(args))
                {
                    alreadyDetected = true;
                    break;
                }
            }

            if (!alreadyDetected)
            {
                detectedInputSources.Add(new InputSourceInfo(args));
            }

            // Create input event
            sourceStateEventData.Initialize(source, sourceId);

            // Pass handler through HandleEvent to perform modal/fallback logic
            HandleEvent(sourceStateEventData, OnSourceDetectedEventHandler);
        }
Пример #5
0
        private void InputSource_SourceLost(object sender, InputSourceEventArgs e)
        {
            // Create input event
            sourceStateEventData.Initialize(e.InputSource, e.SourceId);

            // Pass handler through HandleEvent to perform modal/fallback logic
            HandleEvent(sourceStateEventData, OnSourceLostEventHandler);
        }
        protected void RaiseSourceLostEvent(InputSourceEventArgs e)
        {
            EventHandler <InputSourceEventArgs> handler = SourceLost;

            if (handler != null)
            {
                handler(this, e);
            }
        }
 public SourceData(IInputSource inputSource, uint sourceId)
 {
     SourceId               = sourceId;
     HasPosition            = false;
     SourcePosition         = Vector3.zero;
     IsSourceDown           = false;
     IsSourceDownPending    = false;
     SourceStateChanged     = false;
     SourceStateUpdateTimer = -1;
     InputSourceArgs        = new InputSourceEventArgs(inputSource, sourceId);
 }
 public EditorHandData(IInputSource inputSource, uint handId)
 {
     HandId                 = handId;
     HandPosition           = Vector3.zero;
     HandDelta              = Vector3.zero;
     IsFingerDown           = false;
     IsFingerDownPending    = false;
     FingerStateChanged     = false;
     FingerStateUpdateTimer = -1;
     InputSourceArgs        = new InputSourceEventArgs(inputSource, handId);
 }
Пример #9
0
        private void InputSource_SourceUp(object sender, InputSourceEventArgs e)
        {
            // Create input event
            inputEventData.Initialize(e.InputSource, e.SourceId);

            // Pass handler through HandleEvent to perform modal/fallback logic
            HandleEvent(inputEventData, OnSourceUpEventHandler);

            // UI events
            if (ShouldSendUnityUiEvents)
            {
                PointerEventData unityUIPointerEvent = GazeManager.Instance.UnityUIPointerEvent;
                HandleEvent(unityUIPointerEvent, ExecuteEvents.pointerUpHandler);
            }
        }
Пример #10
0
        public void RaiseSourceLost(IInputSource source, uint sourceId)
        {
            InputSourceEventArgs args = new InputSourceEventArgs(source, sourceId);

            // Manage list of detected sources
            for (int iDetected = 0; iDetected < detectedInputSources.Count; iDetected++)
            {
                if (detectedInputSources[iDetected].Matches(args))
                {
                    detectedInputSources.RemoveAt(iDetected);
                    break;
                }
            }

            // Create input event
            sourceStateEventData.Initialize(source, sourceId);

            // Pass handler through HandleEvent to perform modal/fallback logic
            HandleEvent(sourceStateEventData, OnSourceLostEventHandler);
        }
Пример #11
0
        private void InputSource_SourceDown(object sender, InputSourceEventArgs e)
        {
            // Create input event
            inputEventData.Initialize(e.InputSource, e.SourceId);

            // Pass handler through HandleEvent to perform modal/fallback logic
            HandleEvent(inputEventData, OnSourceDownEventHandler);

            // UI events
            if (ShouldSendUnityUiEvents)
            {
                PointerEventData unityUiPointerEvent = GazeManager.Instance.UnityUIPointerEvent;

                unityUiPointerEvent.eligibleForClick    = true;
                unityUiPointerEvent.delta               = Vector2.zero;
                unityUiPointerEvent.dragging            = false;
                unityUiPointerEvent.useDragThreshold    = true;
                unityUiPointerEvent.pressPosition       = unityUiPointerEvent.position;
                unityUiPointerEvent.pointerPressRaycast = unityUiPointerEvent.pointerCurrentRaycast;

                HandleEvent(unityUiPointerEvent, ExecuteEvents.pointerDownHandler);
            }
        }
 public SourceData(IInputSource inputSource, uint sourceId)
 {
     SourceId = sourceId;
     HasPosition = false;
     SourcePosition = Vector3.zero;
     IsSourceDown = false;
     IsSourceDownPending = false;
     SourceStateChanged = false;
     SourceStateUpdateTimer = -1;
     InputSourceArgs = new InputSourceEventArgs(inputSource, sourceId);
 }
        /// <summary>
        /// Sends the events for source visibility changes.
        /// </summary>
        private void SendSourceVisibilityEvents()
        {
            // Send event for new sources that were added
            foreach (uint newSource in newSources)
            {
                InputSourceEventArgs args = new InputSourceEventArgs(this, newSource);
                RaiseSourceDetectedEvent(args);
            }

            // Send event for sources that are no longer visible and remove them from our dictionary
            foreach (uint existingSource in sourceIdToData.Keys)
            {
                if (!currentSources.Contains(existingSource))
                {
                    pendingSourceIdDeletes.Add(existingSource);
                    InputSourceEventArgs args = new InputSourceEventArgs(this, existingSource);
                    RaiseSourceLostEvent(args);
                }
            }

            // Remove pending source IDs
            for (int i = 0; i < pendingSourceIdDeletes.Count; ++i)
            {
                sourceIdToData.Remove(pendingSourceIdDeletes[i]);
            }
            pendingSourceIdDeletes.Clear();
        }
 protected void RaiseSourceUpEvent(InputSourceEventArgs e)
 {
     EventHandler<InputSourceEventArgs> handler = SourceUp;
     if (handler != null)
     {
         handler(this, e);
     }
 }
 public EditorHandData(IInputSource inputSource, uint handId)
 {
     HandId = handId;
     HandPosition = Vector3.zero;
     HandDelta = Vector3.zero;
     IsFingerDown = false;
     IsFingerDownPending = false;
     FingerStateChanged = false;
     FingerStateUpdateTimer = -1;
     InputSourceArgs = new InputSourceEventArgs(inputSource, handId);
 }