public void InitControllers() { _controller1 = new DrumKitController(null); _controller1.OnButtonEvent += _controller1_OnButtonEvent; _controller2 = new DrumKitController(_controller1.GetDevice()); _controller2.OnButtonEvent += _controller2_OnButtonEvent; }
void _controller2_OnButtonEvent(IMessage m) { if (m.Depress) { _controller2.pedalUp = true; _controller2.leftUp = true; _controller2.rightUp = true; _controller2.downUp = true; _controller2.upUp = true; _controller2.buttonAUp = true; _controller2.buttonBUp = true; _controller2.button1Up = true; _controller2.button2Up = true; _controller2.buttonPlusUp = true; _controller2.buttonMinusUp = true; } if (m.ButtonRedPressed) { _viewModel.Play(Instrument.InstrumentType.Hihat); } if (m.ButtonYellowPressed) { _viewModel.Play(Instrument.InstrumentType.Crash); } if (m.ButtonBluePressed) { _viewModel.Play(Instrument.InstrumentType.Splash); } if (m.ButtonGreenPressed) { _viewModel.Play(Instrument.InstrumentType.Ride, true); } if (m.ButtonAPressed && _controller2.buttonAUp) { // Toggle Metronome _controller2.buttonAUp = false; _viewModel.ToggleMetronome(); } if (m.ButtonBPressed && _controller2.buttonBUp) { // Load saved configuration _controller2.buttonBUp = false; _viewModel.Load(); } if (m.ButtonPlusPressed && _controller2.buttonPlusUp) { _controller2.buttonPlusUp = false; _viewModel.Bpm++; } if (m.ButtonMinusPressed && _controller2.buttonMinusUp) { _controller2.buttonMinusUp = false; _controller1.OnButtonEvent -= _controller1_OnButtonEvent; _controller2.OnButtonEvent -= _controller2_OnButtonEvent; DrumKitController temp = _controller1; _controller1 = _controller2; _controller2 = temp; _controller1.OnButtonEvent += _controller1_OnButtonEvent; _controller2.OnButtonEvent += _controller2_OnButtonEvent; } if (m.RightPressed && _controller2.rightUp) { _controller2.rightUp = false; SelectedIndex++; } if (m.LeftPressed && _controller2.leftUp) { _controller2.leftUp = false; SelectedIndex--; } if (m.UpPressed && _controller2.upUp) { _controller2.upUp = false; _viewModel.Instruments[SelectedIndex].SoundA = _viewModel.Instruments[SelectedIndex].SoundList[(_viewModel.Instruments[SelectedIndex].SoundList.IndexOf(_viewModel.Instruments[SelectedIndex].SoundA) - 1 + _viewModel.Instruments[SelectedIndex].SoundList.Count) % _viewModel.Instruments[SelectedIndex].SoundList.Count]; } if (m.DownPressed && _controller2.downUp) { _controller2.downUp = false; _viewModel.Instruments[SelectedIndex].SoundA = _viewModel.Instruments[SelectedIndex].SoundList[(_viewModel.Instruments[SelectedIndex].SoundList.IndexOf(_viewModel.Instruments[SelectedIndex].SoundA) + 1) % _viewModel.Instruments[SelectedIndex].SoundList.Count]; } if (m.ButtonPedalPressed && _controller2.pedalUp) { _controller2.pedalUp = false; _viewModel.Play(Instrument.InstrumentType.Kick); } if (m.Button1Pressed && _controller2.button1Up) { _controller2.button1Up = false; _viewModel.Instruments[SelectedIndex].PlaySoundA = !_viewModel.Instruments[SelectedIndex].PlaySoundA; } if (m.Button2Pressed && _controller2.button2Up) { _controller2.button2Up = false; foreach (Instrument i in _viewModel.Instruments) { i.PlaySoundA = !i.PlaySoundA; } } }