public void BUT_enable_Click(object sender, EventArgs e) { if (MainV2.joystick == null || MainV2.joystick.enabled == false) { try { if (MainV2.joystick != null) { MainV2.joystick.UnAcquireJoyStick(); } hay_joystick = true; } catch { } // all config is loaded from the xmls Joystick joy = new Joystick(() => MainV2.comPort); joy.elevons = CHK_elevons.Checked; //show error message if a joystick is not connected when Enable is clicked if (!joy.start(CMB_joysticks.Text)) { CustomMessageBox.Show("Please Connect a Joystick", "No Joystick"); joy.Dispose(); hay_joystick = false; return; } Settings.Instance["joystick_name"] = CMB_joysticks.Text; MainV2.joystick = joy; MainV2.joystick.enabled = true; BUT_enable.Text = "Disable"; //timer1.Start(); } else { MainV2.joystick.enabled = false; MainV2.joystick.clearRCOverride(); MainV2.joystick = null; //timer1.Stop(); BUT_enable.Text = "Enable"; } }
private void BUT_enable_Click(object sender, EventArgs e) { if (MainV2.joystick == null || MainV2.joystick.enabled == false) { try { if (MainV2.joystick != null) MainV2.joystick.UnAcquireJoyStick(); } catch { } // all config is loaded from the xmls Joystick joy = new Joystick(); joy.elevons = CHK_elevons.Checked; //show error message if a joystick is not connected when Enable is clicked if (!joy.start(CMB_joysticks.Text)) { CustomMessageBox.Show("Please Connect a Joystick", "No Joystick"); joy.Dispose(); return; } Settings.Instance["joystick_name"] = CMB_joysticks.Text; MainV2.joystick = joy; MainV2.joystick.enabled = true; BUT_enable.Text = "Disable"; //timer1.Start(); } else { MainV2.joystick.enabled = false; MainV2.joystick.clearRCOverride(); MainV2.joystick = null; //timer1.Stop(); BUT_enable.Text = "Enable"; } }