public static getMovingAxis ( string name, int threshold ) : joystickaxis | ||
name | string | |
threshold | int | |
return | joystickaxis |
private void BUT_detch5_Click(object sender, EventArgs e) { CMB_CH5.Text = Joystick.getMovingAxis(CMB_joysticks.Text, 16000).ToString(); }
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; this.SuspendLayout(); 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; } } this.ResumeLayout(); if (MainV2.joystick != null && MainV2.joystick.enabled) { timer1.Start(); BUT_enable.Text = "Disable"; } startup = false; }