private void tabPage5_Enter(object sender, EventArgs e) { joystickComboBox1.Items.Clear(); joystick2ComboBox1.Items.Clear(); joystickComboBox1.Items.Add("None"); joystick2ComboBox1.Items.Add("None"); JoystickController.EnumerateJosticks(); string[] devNames = JoystickController.GetDeviceNames(); for (int f = 0; f < devNames.Length; f++) { joystickComboBox1.Items.Add(devNames[f]); joystick2ComboBox1.Items.Add(devNames[f]); } if (joystickComboBox1.SelectedIndex < 0) { joystickComboBox1.SelectedIndex = 0; } if (joystick2ComboBox1.SelectedIndex < 0) { joystick2ComboBox1.SelectedIndex = 0; } if (joystickComboBox2.SelectedIndex < 0) { joystickComboBox2.SelectedIndex = 0; } if (joystick2ComboBox2.SelectedIndex < 0) { joystick2ComboBox2.SelectedIndex = 0; } if (devNames.Length >= joy1) { joystickComboBox1.SelectedIndex = joy1; } if (devNames.Length >= joy2) { joystick2ComboBox1.SelectedIndex = joy2; } }
public JoystickRemap(Form1 zw, JoystickController jc) { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); joystick = jc; // Set the default dialog font on each child control foreach (Control c in Controls) { c.Font = new System.Drawing.Font(System.Drawing.SystemFonts.MessageBoxFont.FontFamily, c.Font.Size); } if (System.IO.File.Exists(Application.UserAppDataPath + jc.name + ".xml")) { System.Data.DataSet ds = new System.Data.DataSet(); ds.ReadXml(Application.UserAppDataPath + jc.name + ".xml", System.Data.XmlReadMode.InferSchema); dataGridView1.DataSource = ds; } else { for (int f = 0; f < jc.joystick.Caps.NumberButtons; f++) { ButtonKeyCombo buttonKey = new ButtonKeyCombo(); buttonKey.Button = "Button " + (f + 1).ToString(); /* * if (f == 0) { * buttonKey.Key = "Fire"; * jc.fireButtonIndex = 0; * } else */ buttonKey.Key = "None"; ButtonKeyList.Add(buttonKey); } dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = ButtonKeyList; } running = true; joystickPollThread = new System.Threading.Thread(new System.Threading.ThreadStart(JoystickPoll)); joystickPollThread.Name = "Joystick Poll Thread"; joystickPollThread.Priority = System.Threading.ThreadPriority.Lowest; joystickPollThread.Start(); }