public getChannel ( int channel ) : JoyChannel | ||
channel | int | |
Résultat | JoyChannel |
private void Joystick_Load(object sender, EventArgs e) { try { DeviceList joysticklist = Joystick.getDevices(); foreach (DeviceInstance device in joysticklist) { CMB_joysticks.Items.Add(device.ProductName); } } catch { CustomMessageBox.Show("Error geting joystick list: do you have the directx redist installed?"); this.Close(); return; } if (CMB_joysticks.Items.Count > 0 && CMB_joysticks.SelectedIndex == -1) CMB_joysticks.SelectedIndex = 0; try { if (MainV2.config.ContainsKey("joystick_name") && MainV2.config["joystick_name"].ToString() != "") CMB_joysticks.Text = MainV2.config["joystick_name"].ToString(); } catch { } CMB_CH1.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH2.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH3.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH4.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH5.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH6.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH7.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH8.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); try { CHK_elevons.Checked = bool.Parse(MainV2.config["joy_elevons"].ToString()); } catch { } // IF 1 DOESNT EXIST NONE WILL var tempjoystick = new Joystick(); label14.Text += " " + MainV2.comPort.MAV.cs.firmware.ToString(); for (int a = 1; a <= 8; a++) { var config = tempjoystick.getChannel(a); findandsetcontrol("CMB_CH" + a, config.axis.ToString()); findandsetcontrol("revCH" + a, config.reverse.ToString()); findandsetcontrol("expo_ch" + a, config.expo.ToString()); } if (MainV2.joystick != null && MainV2.joystick.enabled) { timer1.Start(); BUT_enable.Text = "Disable"; } startup = false; }
private void Joystick_Load(object sender, EventArgs e) { try { DeviceList joysticklist = Joystick.getDevices(); foreach (DeviceInstance device in joysticklist) { CMB_joysticks.Items.Add(device.ProductName); } } catch { CustomMessageBox.Show("Error geting joystick list: do you have the directx redist installed?"); this.Close(); return; } if (CMB_joysticks.Items.Count > 0) CMB_joysticks.SelectedIndex = 0; CMB_CH1.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH2.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH3.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH4.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH5.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH6.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH7.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH8.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); try { /* //CMB_CH1 CMB_CH1.Text = MainV2.config["CMB_CH1"].ToString(); CMB_CH2.Text = MainV2.config["CMB_CH2"].ToString(); CMB_CH3.Text = MainV2.config["CMB_CH3"].ToString(); CMB_CH4.Text = MainV2.config["CMB_CH4"].ToString(); CMB_CH5.Text = MainV2.config["CMB_CH5"].ToString(); CMB_CH6.Text = MainV2.config["CMB_CH6"].ToString(); CMB_CH7.Text = MainV2.config["CMB_CH7"].ToString(); CMB_CH8.Text = MainV2.config["CMB_CH8"].ToString(); //revCH1 revCH1.Checked = bool.Parse(MainV2.config["revCH1"].ToString()); revCH2.Checked = bool.Parse(MainV2.config["revCH2"].ToString()); revCH3.Checked = bool.Parse(MainV2.config["revCH3"].ToString()); revCH4.Checked = bool.Parse(MainV2.config["revCH4"].ToString()); revCH5.Checked = bool.Parse(MainV2.config["revCH5"].ToString()); revCH6.Checked = bool.Parse(MainV2.config["revCH6"].ToString()); revCH7.Checked = bool.Parse(MainV2.config["revCH7"].ToString()); revCH8.Checked = bool.Parse(MainV2.config["revCH8"].ToString()); //expo_ch1 expo_ch1.Text = MainV2.config["expo_ch1"].ToString(); expo_ch2.Text = MainV2.config["expo_ch2"].ToString(); expo_ch3.Text = MainV2.config["expo_ch3"].ToString(); expo_ch4.Text = MainV2.config["expo_ch4"].ToString(); expo_ch5.Text = MainV2.config["expo_ch5"].ToString(); expo_ch6.Text = MainV2.config["expo_ch6"].ToString(); expo_ch7.Text = MainV2.config["expo_ch7"].ToString(); expo_ch8.Text = MainV2.config["expo_ch8"].ToString(); */ CHK_elevons.Checked = bool.Parse(MainV2.config["joy_elevons"].ToString()); } catch { } // IF 1 DOESNT EXIST NONE WILL var tempjoystick = new Joystick(); for (int a = 1; a <= 8; a++) { var config = tempjoystick.getChannel(a); findandsetcontrol("CMB_CH" + a, config.axis.ToString()); findandsetcontrol("revCH" + a, config.reverse.ToString()); findandsetcontrol("expo_ch" + a, config.expo.ToString()); } if (MainV2.joystick != null && MainV2.joystick.enabled) { timer1.Start(); BUT_enable.Text = "Disable"; } startup = false; }
private void Joystick_Load(object sender, EventArgs e) { try { var joysticklist = Joystick.getDevices(); foreach (DeviceInstance device in joysticklist) { CMB_joysticks.Items.Add(device.ProductName.TrimUnPrintable()); } } catch { CustomMessageBox.Show("Error geting joystick list: do you have the directx redist installed?"); this.Close(); return; } if (CMB_joysticks.Items.Count > 0 && CMB_joysticks.SelectedIndex == -1) { CMB_joysticks.SelectedIndex = 0; } try { if (Settings.Instance.ContainsKey("joystick_name") && Settings.Instance["joystick_name"].ToString() != "") { CMB_joysticks.Text = Settings.Instance["joystick_name"].ToString(); } } catch { } try { if (Settings.Instance.ContainsKey("joy_elevons")) { CHK_elevons.Checked = bool.Parse(Settings.Instance["joy_elevons"].ToString()); } } catch { } // IF 1 DOESNT EXIST NONE WILL var tempjoystick = new Joystick(() => MainV2.comPort); label14.Text += " " + MainV2.comPort.MAV.cs.firmware.ToString(); var y = label8.Bottom; for (int a = 1; a <= maxaxis; a++) { var config = tempjoystick.getChannel(a); var ax = new JoystickAxis() { ChannelNo = a, Label = "Ch " + a, AxisArray = (Enum.GetValues(typeof(Joystick.joystickaxis))), ChannelValue = config.axis.ToString(), ExpoValue = config.expo.ToString(), ReverseValue = config.reverse, Location = new Point(0, y), Name = "axis" + a }; ax.Detect = () => Joystick.getMovingAxis(CMB_joysticks.Text, 16000).ToString(); ax.Reverse = () => MainV2.joystick.setReverse(ax.ChannelNo, ax.ReverseValue); ax.SetAxis = () => MainV2.joystick.setAxis(ax.ChannelNo, (Joystick.joystickaxis)Enum.Parse(typeof(Joystick.joystickaxis), ax.ChannelValue)); ax.GetValue = () => { return((short)MainV2.comPort.MAV.cs.GetType().GetField("rcoverridech" + ax.ChannelNo) .GetValue(MainV2.comPort.MAV.cs)); }; Controls.Add(ax); y += ax.Height; if ((ax.Bottom + 30) > this.Height) { this.Height = ax.Bottom; } if ((ax.Right) > this.Width) { this.Width = ax.Right; } } if (MainV2.joystick != null && MainV2.joystick.enabled) { timer1.Start(); BUT_enable.Text = "Disable"; } startup = false; }
private void Joystick_Load(object sender, EventArgs e) { try { var joysticklist = Joystick.getDevices(); foreach (DeviceInstance device in joysticklist) { CMB_joysticks.Items.Add(device.ProductName); } } catch { CustomMessageBox.Show("Error geting joystick list: do you have the directx redist installed?"); this.Close(); return; } if (CMB_joysticks.Items.Count > 0 && CMB_joysticks.SelectedIndex == -1) { CMB_joysticks.SelectedIndex = 0; } try { if (Settings.Instance.ContainsKey("joystick_name") && Settings.Instance["joystick_name"].ToString() != "") { CMB_joysticks.Text = Settings.Instance["joystick_name"].ToString(); } } catch { } CMB_CH1.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH2.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH3.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH4.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH5.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH6.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH7.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); CMB_CH8.DataSource = (Enum.GetValues(typeof(Joystick.joystickaxis))); try { if (Settings.Instance.ContainsKey("joy_elevons")) { CHK_elevons.Checked = bool.Parse(Settings.Instance["joy_elevons"].ToString()); } } catch { } // IF 1 DOESNT EXIST NONE WILL var tempjoystick = new Joystick(); label14.Text += " " + MainV2.comPort.MAV.cs.firmware.ToString(); for (int a = 1; a <= 8; a++) { var config = tempjoystick.getChannel(a); findandsetcontrol("CMB_CH" + a, config.axis.ToString()); findandsetcontrol("revCH" + a, config.reverse.ToString()); findandsetcontrol("expo_ch" + a, config.expo.ToString()); } if (MainV2.joystick != null && MainV2.joystick.enabled) { timer1.Start(); BUT_enable.Text = "Disable"; } startup = false; }
private void timer1_Tick(object sender, EventArgs e) { try { if (MainV2.joystick == null || MainV2.joystick.enabled == false) { //Console.WriteLine(DateTime.Now.Millisecond + " start "); Joystick joy = MainV2.joystick; if (joy == null) { joy = new Joystick(() => MainV2.comPort); for (int a = 1; a <= maxaxis; a++) { var config = joy.getChannel(a); joy.setChannel(a, config.axis, config.reverse, config.expo); } joy.elevons = CHK_elevons.Checked; joy.AcquireJoystick(CMB_joysticks.Text); joy.name = CMB_joysticks.Text; noButtons = joy.getNumButtons(); noButtons = Math.Min(16, noButtons); SuspendLayout(); MainV2.joystick = joy; var maxctl = Controls.Find("axis" + 1, false).FirstOrDefault(); for (int f = 0; f < noButtons; f++) { string name = (f).ToString(); doButtontoUI(name, maxctl.Right + 100, maxctl.Top + f * maxctl.Height); var config = joy.getButton(f); joy.setButton(f, config); } ResumeLayout(); ThemeManager.ApplyThemeTo(this); CMB_joysticks.SelectedIndex = CMB_joysticks.Items.IndexOf(joy.name); } MainV2.joystick.elevons = CHK_elevons.Checked; MainV2.comPort.MAV.cs.rcoverridech1 = joy.getValueForChannel(1, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech2 = joy.getValueForChannel(2, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech3 = joy.getValueForChannel(3, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech4 = joy.getValueForChannel(4, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech5 = joy.getValueForChannel(5, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech6 = joy.getValueForChannel(6, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech7 = joy.getValueForChannel(7, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech8 = joy.getValueForChannel(8, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech9 = joy.getValueForChannel(9, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech10 = joy.getValueForChannel(10, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech11 = joy.getValueForChannel(11, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech12 = joy.getValueForChannel(12, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech13 = joy.getValueForChannel(13, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech14 = joy.getValueForChannel(14, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech15 = joy.getValueForChannel(15, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech16 = joy.getValueForChannel(16, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech17 = joy.getValueForChannel(17, CMB_joysticks.Text); MainV2.comPort.MAV.cs.rcoverridech18 = joy.getValueForChannel(18, CMB_joysticks.Text); //Console.WriteLine(DateTime.Now.Millisecond + " end "); } } catch (SharpDX.SharpDXException ex) { ex.ToString(); if (MainV2.joystick != null && MainV2.joystick.enabled == true) { BUT_enable_Click(null, null); } if (ex.Message.Contains("DIERR_NOTACQUIRED")) { MainV2.joystick = null; } } catch { } try { for (int f = 0; f < noButtons; f++) { string name = (f).ToString(); var items = this.Controls.Find("hbar" + name, false); if (items.Length > 0) { ((HorizontalProgressBar)items[0]).Value = MainV2.joystick.isButtonPressed(f) ? 100 : 0; } } } catch { } // this is for buttons - silent fail }