Exemplo n.º 1
0
        private void mInputDevice_NoteOn(NoteOnMessage msg)
        {
            LaunchpadButton button = GetButton(msg.Pitch);

            if (button == null)
            {
                return;
            }
            button.State = (ButtonPressState)msg.Velocity;
            if (ButtonPressed == null)
            {
                return;
            }


            var pressEventArgs = (int)msg.Pitch % 16 == 8 ? new ButtonPressEventArgs((SideButton)((int)msg.Pitch / 16), button) : new ButtonPressEventArgs((int)msg.Pitch % 16, (int)msg.Pitch / 16, button);

            if (button.State == ButtonPressState.Up)
            {
                ButtonPressed?.Invoke(this, pressEventArgs);
                ButtonUp?.Invoke(this, pressEventArgs);
            }
            else
            {
                ButtonDown?.Invoke(this, pressEventArgs);
            }
        }
 public ButtonPressEventArgs(int x, int y, LaunchpadButton button, int index = 0)
 {
     this.mType   = ButtonType.Grid;
     this.mX      = x;
     this.mY      = y;
     this.mButton = button;
     this.mIndex  = index;
 }
Exemplo n.º 3
0
 private void InitialiseButtons()
 {
     for (int index = 0; index < 8; ++index)
     {
         mToolbar[index] = new LaunchpadButton(this, ButtonType.Toolbar, 104 + index);
         mSide[index]    = new LaunchpadButton(this, ButtonType.Side, index * 16 + 8);
     }
     for (int index1 = 0; index1 < 8; ++index1)
     {
         for (int index2 = 0; index2 < 8; ++index2)
         {
             mGrid[index2, index1] = new LaunchpadButton(this, ButtonType.Grid, index1 * 16 + index2);
         }
     }
 }
Exemplo n.º 4
0
        private void mInputDevice_ControlChange(ControlChangeMessage msg)
        {
            ToolbarButton   toolbarButton = (ToolbarButton)(msg.Control - 104);
            LaunchpadButton button        = GetButton(toolbarButton);

            if (button == null)
            {
                return;
            }
            button.State = (ButtonPressState)msg.Value;

            var pressEventArgs = new ButtonPressEventArgs(toolbarButton, button);

            if (button.State == ButtonPressState.Up)
            {
                ButtonPressed?.Invoke(this, pressEventArgs);
                ButtonUp?.Invoke(this, pressEventArgs);
            }
            else
            {
                ButtonDown?.Invoke(this, pressEventArgs);
            }
        }
 public ButtonPressEventArgs(SideButton sideButton, LaunchpadButton button)
 {
     this.mType          = ButtonType.Side;
     this.mSidebarButton = sideButton;
     this.mButton        = button;
 }
 public ButtonPressEventArgs(ToolbarButton toolbarButton, LaunchpadButton button)
 {
     this.mType          = ButtonType.Toolbar;
     this.mToolbarButton = toolbarButton;
     this.mButton        = button;
 }