private void btnConnect_Click(object sender, EventArgs e) { UsbDeviceInfo info = (UsbDeviceInfo)ddlUsbController.SelectedItem; string vid = info.DeviceID.Substring(info.DeviceID.IndexOf("VID_") + 4, 4); string pid = info.DeviceID.Substring(info.DeviceID.IndexOf("PID_") + 4, 4); int iVid = int.Parse(vid, System.Globalization.NumberStyles.AllowHexSpecifier); int iPid = int.Parse(pid, System.Globalization.NumberStyles.AllowHexSpecifier); if (m_DrumController != null) { m_DrumController.Dispose(); m_DrumController.ButtonPressedEvent -= DrumButtonPressed; m_DrumController.ButtonReleasedEvent -= DrumButtonReleased; m_DrumController.DPadStateChanged -= DrumDPadStateChanged; } switch ((ControllerType)ddlController.SelectedItem) { case ControllerType.Xbox360_GHWT_GH5_Drum: m_DrumController = new GHWTDrumController(this, iPid, iVid); break; case ControllerType.Ps3_RockBandProDrum: m_DrumController = new ProDrumController(this, iPid, iVid); break; } m_DrumController.ButtonPressedEvent += DrumButtonPressed; m_DrumController.ButtonReleasedEvent += DrumButtonReleased; m_DrumController.DPadStateChanged += DrumDPadStateChanged; }