/// <summary>
 /// Called whenever button pressure changes.
 /// </summary>
 internal void RaiseStylusButtonChanged(StylusButtonData value)
 {
     if (OnStylusButton != null)
     {
         OnStylusButton(value.SourceID, value.Pressure);
     }
 }
Example #2
0
        /// <summary>
        /// Changes of button pressure are handled here
        /// </summary>
        /// <param name="stylusOutput">Output pressure</param>
        /// <param name="value"> Input preassure</param>
        private void ExecuteStylusButtonHandler(StylusButtonData stylusOutput, StylusButtonData value)
        {
            CheckButtonThresholds(value);
            ButtonThresholdCalculator calculator = _buttonThresholdCalculators[value.SourceID];

            value.Pressure = calculator.AddValue(value).Pressure;
            RaiseButtonHandlers(stylusOutput, value);
        }
 /// <summary>
 /// Called when button is pressed or released.
 /// </summary>
 internal void RaiseStylusButtonPressed(StylusButtonPressedHandler handler, StylusButtonData value)
 {
     if (handler != null)
     {
         handler(value.SourceID);
     }
     else
     {
         Debug.Log("Handler " + handler.ToString() + " has no registration");
     }
 }
Example #4
0
        internal void RaiseButtonHandlers(StylusButtonData stylusOutput, StylusButtonData value)
        {
            //before 0 now bigger then 0
            if (stylusOutput.Pressure == 0 && value.Pressure > 0)
            {
                InputInstance.RaiseStylusButtonDown(value);
            }

            if (stylusOutput.Pressure > 0 && value.Pressure == 0)
            {
                InputInstance.RaiseStylusButtonUp(value);
            }

            if (value.Pressure != 0)
            {
                InputInstance.RaiseStylusButtonChanged(value);
            }
        }
Example #5
0
        private void CheckButtonThresholds(StylusButtonData value)
        {
            //checking if preassure is lower then dead zone
            if (value.Pressure < InputThresholds.ButtonDeadzone)
            {
                value.Pressure = Globals.MIN_BUTTON_PRESSURE;
            }

            //checking if preassure is higher then gravity
            if (value.Pressure > InputThresholds.ButtonGravity)
            {
                value.Pressure = Globals.MAX_BUTTON_PRESSURE;
            }

            //smooth movement according to threshold
            if (_buttonThresholdCalculators == null)
            {
                _buttonThresholdCalculators = new List <ButtonThresholdCalculator>(2)
                {
                    new ButtonThresholdCalculator(Globals.DEFAULT_FRAME_RATE, InputThresholds),
                    new ButtonThresholdCalculator(Globals.DEFAULT_FRAME_RATE, InputThresholds)
                };
            }
        }
 internal void RaiseStylusButtonUp(StylusButtonData value)
 {
     RaiseStylusButtonPressed(OnStylusButtonUp, value);
 }