private void frmMain_Load(object sender, EventArgs e) { // grab the joystick jst = new JoystickInterface.Joystick(this.Handle); string[] sticks = jst.FindJoysticks(); jst.AcquireJoystick(sticks[0]); // add the axis controls to the axis container for (int i = 0; i < jst.AxisCount; i++) { Axis ax = new Axis(); ax.AxisId = i + 1; flpAxes.Controls.Add(ax); } // add the button controls to the button container for (int i = 0; i < jst.Buttons.Length; i++) { JoystickSample.Button btn = new Button(); btn.ButtonId = i + 1; btn.ButtonStatus = jst.Buttons[i]; flpButtons.Controls.Add(btn); } // start updating positions tmrUpdateStick.Enabled = true; }
private void frmMain_Load(object sender, EventArgs e) { jst = new JoystickInterface.Joystick(this.Handle); updateDeviceList(); updateInterval(refreshInterval); tmrButtonStatus.Enabled = true; }
private void frmMain_Load(object sender, EventArgs e) { // grab the joystick jst = new JoystickInterface.Joystick(this.Handle); string[] sticks = jst.FindJoysticks(); jst.AcquireJoystick(sticks[0]); // add the axis controls to the axis container for (int i = 0; i < jst.AxisCount; i++) { Axis ax = new Axis(); ax.AxisId = i + 1; flpAxes.Controls.Add(ax); } // add the button controls to the button container for (int i = 0; i < jst.Buttons.Length; i++) { JoystickSample.Button btn = new Button(); btn.ButtonId = i + 1; btn.ButtonStatus = jst.Buttons[i]; flpButtons.Controls.Add(btn); } // start updating positions tmrUpdateStick.Enabled = true; }
private void button1_Click(object sender, EventArgs e) { //MessageBox.Show("Loading"); // grab the joystick jst = new JoystickInterface.Joystick(this.Handle); string[] sticks = jst.FindJoysticks(); jst.AcquireJoystick(sticks[0]); //MessageBox.Show("Joystick Acquired"); // start updating positions tmrUpdateStick.Enabled = true; }
public DrumPadEvent(Form parent) { Stick = new JoystickInterface.Joystick(parent.Handle); string[] st = Stick.FindJoysticks(); Stick.AcquireJoystick(st[0]); ButtonReady = new bool[Stick.Buttons.Length]; mmTimer.Period = 10; mmTimer.Mode = Multimedia.TimerMode.Periodic; mmTimer.Tick += new EventHandler(CheckTimer_Tick); mmTimer.Start(); for (int i = 0; i < ButtonReady.Length; i++) { ButtonReady[i] = false; } }
void getJoysticks() { cbJoySticks.SelectedIndexChanged -= CbJoySticksSelectedIndexChanged; try { jst = new JoystickInterface.Joystick(this.Handle); sticks = jst.FindJoysticks(); foreach (string joyName in sticks) { cbJoySticks.Items.Add(joyName); } } catch {} //(Exception ex) { MessageBox.Show(ex.Message); } cbJoySticks.SelectedIndexChanged += CbJoySticksSelectedIndexChanged; if (cbJoySticks.Items.Count > 0) { cbJoySticks.SelectedIndex = 0; } }
static void setupJoystick() { _jst = new JoystickInterface.Joystick(Process.GetCurrentProcess().MainWindowHandle); string[] sticks = _jst.FindJoysticks(); _jst.AcquireJoystick(sticks[0]); }
private void button2_Click(object sender, EventArgs e) { Axis ax = new Axis(); int i = 0; // Find all the GameControl devices that are attached. // check that we have at least one device. if (!(check == 1)) //not connected { DeviceList gameControllerList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); // check that we have at least one device. if (gameControllerList.Count > 0) { check = 1; // grab the joystick jst = new JoystickInterface.Joystick(this.Handle); string[] sticks = jst.FindJoysticks(); jst.AcquireJoystick(sticks[0]); // add the axis controls to the axis container for (i = 0; i < jst.AxisCount; i++) { ax = new Axis(); ax.AxisId = i + 1; flpAxes.Controls.Add(ax); } /////////////////////////////////////////////////// ax = new Axis(); ax.AxisId = i + 1; flpAxes.Controls.Add(ax); ////////////////////////////////////////////////// // add the button controls to the button container for (i = 0; i < 11; i++) { JoystickSample.Button btn = new Button(); btn.ButtonId = i + 1; btn.ButtonStatus = jst.Buttons[i]; flpButtons.Controls.Add(btn); } // start updating positions tmrUpdateStick.Enabled = true; MessageBox.Show("Joystick Connected"); } else { check = 0; MessageBox.Show("No Joystick detected"); } } else { check = 1; MessageBox.Show("Joystick already connected"); } }
static void setupJoystick() { _jst = new JoystickInterface.Joystick(Process.GetCurrentProcess().MainWindowHandle); string[] sticks = _jst.FindJoysticks(); _jst.AcquireJoystick(sticks[0]); }
private void Form1_Load(object sender, EventArgs e) { #region 初始化下拉串口名称列表框 //获取单片机与计算机连接的端口号 string[] ports = SerialPort.GetPortNames(); Array.Sort(ports); //将其显示到comboPorName控件中去 comboBoxPortNum.Items.AddRange(ports); comboBoxPortNum.SelectedIndex = comboBoxPortNum.Items.Count > 0 ? 0 : -1; //波特率默认为9600bps,可以通过下拉选项进行调节 comboBoxBundRate.SelectedIndex = comboBoxBundRate.Items.IndexOf("9600"); #endregion //下面这句还不太懂,先照着做 serialPort1.NewLine = "\r\n"; //与设置RTS信号有关,虽不明,但觉厉,照着做 serialPort1.RtsEnable = true; //注册对串口接收数据的响应方法 serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived); // grab the joystick jst = new JoystickInterface.Joystick(this.Handle); string[] sticks = jst.FindJoysticks(); jst.AcquireJoystick(sticks[0]); textBoxDevice.Text = jst.ToString(); // start updating positions timer1.Enabled = true; }
void getJoysticks() { cbJoySticks.SelectedIndexChanged -= CbJoySticksSelectedIndexChanged; try { jst = new JoystickInterface.Joystick(this.Handle); sticks = jst.FindJoysticks(); foreach(string joyName in sticks) cbJoySticks.Items.Add(joyName); } catch {} //(Exception ex) { MessageBox.Show(ex.Message); } cbJoySticks.SelectedIndexChanged += CbJoySticksSelectedIndexChanged; if(cbJoySticks.Items.Count > 0) cbJoySticks.SelectedIndex = 0; }