Exemple #1
0
        private void OnReport(HidReport report)
        {
            if (attached == false)
            {
                return;
            }

            if (report.Data.Length >= 6)
            {
                PowerMateState state = ParseState(report.Data);
                if (!state.IsValid)
                {
                    System.Diagnostics.Debug.WriteLine("Invalid PowerMate state");
                }
                else
                {
                    GenerateEvents(state);

                    if (debugPrintRawMessages)
                    {
                        System.Diagnostics.Debug.Write("PowerMate raw data: ");
                        for (int i = 0; i < report.Data.Length; i++)
                        {
                            System.Diagnostics.Debug.Write(String.Format("{0:000} ", report.Data[i]));
                        }
                        System.Diagnostics.Debug.WriteLine("");
                    }
                }
            }

            device.ReadReport(OnReport);
        }
Exemple #2
0
        private void OnButtonUp(PowerMateState state)
        {
            var handle = ButtonUp;

            if (handle != null)
            {
                handle(this, new PowerMateEventArgs(state));
            }
        }
Exemple #3
0
        private void OnKnobDisplacement(PowerMateState state)
        {
            var handle = KnobDisplacement;

            if (handle != null)
            {
                handle(this, new PowerMateEventArgs(state));
            }
        }
Exemple #4
0
        private void GenerateEvents(PowerMateState state)
        {
            if (state.ButtonState == PowerMateButtonState.Down && prevState.ButtonState == PowerMateButtonState.Up)
            {
                OnButtonDown(state);
            }
            else if (state.ButtonState == PowerMateButtonState.Up && prevState.ButtonState == PowerMateButtonState.Down)
            {
                OnButtonUp(state);
            }

            if (state.KnobDisplacement != 0)
            {
                OnKnobDisplacement(state);
            }

            prevState = state;
        }
 /// <summary>
 /// Initializes a new instance of the PowerMateEventArgs class.
 /// </summary>
 /// <param name="state"></param>
 public PowerMateEventArgs(PowerMateState state)
 {
     State = state;
 }
 private void UpdateGUIFromState(PowerMateState state)
 {
     buttonLabel.Text = state.ButtonState == PowerMateButtonState.Up ? "Up" : "Down";
     rotationLabel.Text = state.KnobDisplacement.ToString();
     ledBrightnessLabel.Text = state.LedBrightness.ToString();
     ledPulseLabel.Text = state.LedPulseEnabled ? "On" : "Off";
     ledPulseSpeedLabel.Text = state.LedPulseSpeed.ToString();
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the PowerMateManager class.
 /// </summary>
 public PowerMateManager()
 {
     prevState = new PowerMateState(PowerMateButtonState.Up, 0, 0, false, false, 0);
 }
 /// <summary>
 /// Initializes a new instance of the PowerMateEventArgs class.
 /// </summary>
 /// <param name="state"></param>
 public PowerMateEventArgs(PowerMateState state)
 {
     State = state;
 }
 /// <summary>
 /// Initializes a new instance of the PowerMateManager class.
 /// </summary>
 public PowerMateManager()
 {
     prevState = new PowerMateState(PowerMateButtonState.Up, 0, 0, false, false, 0);
 }
        private void GenerateEvents(PowerMateState state)
        {
            if (state.ButtonState == PowerMateButtonState.Down && prevState.ButtonState == PowerMateButtonState.Up)
                OnButtonDown(state);
            else if (state.ButtonState == PowerMateButtonState.Up && prevState.ButtonState == PowerMateButtonState.Down)
                OnButtonUp(state);

            if (state.KnobDisplacement != 0)
                OnKnobDisplacement(state);

            prevState = state;
        }
 private void OnKnobDisplacement(PowerMateState state)
 {
     var handle = KnobDisplacement;
     if (handle != null)
     {
         handle(this, new PowerMateEventArgs(state));
     }
 }
 private void OnButtonUp(PowerMateState state)
 {
     var handle = ButtonUp;
     if (handle != null)
     {
         handle(this, new PowerMateEventArgs(state));
     }
 }