コード例 #1
0
ファイル: MainForm.cs プロジェクト: Xtreamer/WiiJoy
        private void OnNewPositionDataRecieved(object sender, SerialPortDataParser.PositionDataEventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new EventHandler<SerialPortDataParser.PositionDataEventArgs>(OnNewPositionDataRecieved), new object[] { sender, e });
                return;
            }

            int maxTextLength = 1000;
            if (tbData.TextLength > maxTextLength)
                tbData.Text = tbData.Text.Remove(0, tbData.TextLength - maxTextLength);

            rollTextBox.Text = e.Roll.ToString();
            pitchTextBox.Text = e.Pitch.ToString();
            yawTextBox.Text = e.Yaw.ToString();
            throttleTextBox.Text = e.Throttle.ToString();
            aux1TextBox.Text = e.Aux1.ToString();

            elapsedLabel.Text = e.TimeSinceLast.ToString() + " ms";
        }
コード例 #2
0
ファイル: VJoyManager.cs プロジェクト: Xtreamer/WiiJoy
        public void SetPositions(object sender, SerialPortDataParser.PositionDataEventArgs e)
        {
            iReport.bDevice = (byte)deviceId;
            iReport.AxisX = ScaleValue(e.Roll, xMinVal, xMaxVal);
            iReport.AxisY = ScaleValue(e.Pitch, yMinVal, yMaxVal);
            iReport.AxisZ = ScaleValue(e.Throttle, yMinVal, yMaxVal);
            iReport.AxisZRot = ScaleValue(e.Yaw, xMinVal, xMaxVal);
            iReport.AxisXRot = 0;

            var updateSucceeded = joystick.UpdateVJD(deviceId, ref iReport);
            if (!updateSucceeded)
            {
                Console.WriteLine("Feeding vJoy device number {0} failed - try to enable device then press enter\n", deviceId);
                joystick.AcquireVJD(deviceId);
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Xtreamer/WiiJoy
        private void UserInitialization()
        {
            _parser = new SerialPortDataParser();
            _serialPortManager = new SerialPortManager();
            _vJoyManager = new VJoyManager();

            var mySerialSettings = _serialPortManager.CurrentSerialSettings;
            serialSettingsBindingSource.DataSource = mySerialSettings;
            portNameComboBox.DataSource = mySerialSettings.PortNameCollection;
            baudRateComboBox.DataSource = mySerialSettings.BaudRateCollection;
            dataBitsComboBox.DataSource = mySerialSettings.DataBitsCollection;
            parityComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.Parity));
            stopBitsComboBox.DataSource = Enum.GetValues(typeof(System.IO.Ports.StopBits));

            _serialPortManager.NewSerialDataRecieved += NewSerialDataRecieved;
            _serialPortManager.NewSerialDataRecieved += _parser.NewSerialDataReceived;
            _parser.NewPositionDataRecieved += _vJoyManager.SetPositions;
            _parser.NewPositionDataRecieved += OnNewPositionDataRecieved;
            this.FormClosing += MainForm_FormClosing;
        }