Exemplo n.º 1
0
 /// <summary>
 /// Output information content via audio if input was received 
 /// for a device currently in this haptic rectangle
 /// </summary>
 /// <param name="haptiQ"></param>
 /// <param name="gestureType"></param>
 public override void handlePress(HaptiQ haptiQ, PRESSURE_GESTURE_TYPE gestureType)
 {
     Tuple<STATE, IBehaviour> HaptiQState = _HaptiQBehaviours.ContainsKey(haptiQ.getID()) ? _HaptiQBehaviours[haptiQ.getID()] : null;
     if (pointIsInside(haptiQ.position) && HaptiQState != null && HaptiQState.Item1 == STATE.down)
     {
         if (_action != null)
         {
             _action.run(haptiQ.getID(), gestureType, haptiQ.getCurrentPressureData());
         }
         else
         {
             SpeechOutput.Instance.speak(information);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Handle an actuator press. 
 /// Note: Multiple presses are not supported, yet.
 /// </summary>
 /// <param name="haptiQ"></param>
 /// <param name="gestureType"></param>
 public virtual void handlePress(HaptiQ haptiQ, PRESSURE_GESTURE_TYPE gestureType)
 {
     Tuple<STATE, IBehaviour> HaptiQState = _HaptiQBehaviours.ContainsKey(haptiQ.getID()) ? _HaptiQBehaviours[haptiQ.getID()] : null;
     if (pointIsInside(haptiQ.position) && HaptiQState != null && HaptiQState.Item1 == STATE.down)
     {
         if (_action != null)
         {
             _action.run(haptiQ.getID(), gestureType, haptiQ.getCurrentPressureData());
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Handle behaviours on input
        /// </summary>
        /// <param name="haptiQ"></param>
        /// <returns></returns>
        public Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour> handleInput(HaptiQ haptiQ)
        {
            if (this.Parent != null)
            {
                Tuple<STATE, IBehaviour> HaptiQState = _HaptiQBehaviours.ContainsKey(haptiQ.getID()) ? _HaptiQBehaviours[haptiQ.getID()] : null;
                if (pointIsInside(haptiQ.position))
                {
                    IBehaviour prevBehaviour = HaptiQState != null ? HaptiQState.Item2 : null;
                    IBehaviour currentBehaviour = chooseBehaviour(haptiQ);
                    currentBehaviour.updateNext(prevBehaviour);

                    BEHAVIOUR_RULES rule = BEHAVIOUR_RULES.SUBS;
                    if (currentBehaviour.Equals(prevBehaviour))
                    {
                        rule = BEHAVIOUR_RULES.NOPE;
                    }
                    _HaptiQBehaviours[haptiQ.getID()] = new Tuple<STATE, IBehaviour>(STATE.down, currentBehaviour);
                    return new Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour>(rule, currentBehaviour, prevBehaviour);
                }
                else if (HaptiQState != null && HaptiQState.Item1 == STATE.down)
                {
                    IBehaviour prevBehaviour = HaptiQState.Item2;
                    IBehaviour currentBehaviour = new BasicBehaviour(haptiQ, BasicBehaviour.TYPES.flat);
                    BEHAVIOUR_RULES rule = BEHAVIOUR_RULES.SUBS;
                    if (currentBehaviour.Equals(prevBehaviour))
                    {
                        rule = BEHAVIOUR_RULES.NOPE;
                    }
                    _HaptiQBehaviours[haptiQ.getID()] = new Tuple<STATE, IBehaviour>(STATE.up, currentBehaviour);
                    return new Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour>(rule, currentBehaviour, prevBehaviour);
                }
            }

            Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour> retval = 
                new Tuple<BEHAVIOUR_RULES, IBehaviour, IBehaviour>(BEHAVIOUR_RULES.REMOVE,
                    _HaptiQBehaviours.ContainsKey(haptiQ.getID()) ? _HaptiQBehaviours[haptiQ.getID()].Item2 : null, null);
            _HaptiQBehaviours[haptiQ.getID()] = new Tuple<STATE, IBehaviour>(STATE.up, null);
            return retval;
        }