コード例 #1
0
        private void connect()
        {
            if (comboJoysticks1.SelectedItem != null)
            {
                try {
                    VJoy1 = vJoyEnumerator1.GetVJoy(comboJoysticks1.SelectedItem.ToString());
                    joy1  = comboJoysticks1.SelectedIndex;
                }
                catch (VJoyBase.VJoyException ex) {
                    ErrorMessageBox(ex.Message, "VJoy Error");
                    return;
                }
            }

            if (comboJoysticks2.SelectedItem != null)
            {
                try
                {
                    VJoy2 = vJoyEnumerator2.GetVJoy(comboJoysticks2.SelectedItem.ToString());
                    joy2  = comboJoysticks2.SelectedIndex;
                }
                catch (VJoyBase.VJoyException ex)
                {
                    ErrorMessageBox(ex.Message, "VJoy Error");
                    return;
                }
            }

            serialReader = createSerialReader();

            var sp = useCustomSerialParameters ?
                     serialParameters
                                : serialReader.GetDefaultSerialParameters();

            if (!serialReader.OpenPort((string)comboPorts.SelectedItem, sp))
            {
                ErrorMessageBox("Can not open the port", "Serial Error");
                VJoy1.Release();
                VJoy2.Release();
                return;
            }

            comboProtocol.Enabled       = false;
            comboPorts.Enabled          = false;
            buttonPortSetup.Enabled     = false;
            buttonPortsRefresh.Enabled  = false;
            buttonProtocolSetup.Enabled = false;
            buttonConnect.Text          = "Disconnect";
            comboJoysticks1.Enabled     = false;
            comboJoysticks2.Enabled     = false;
            toolStripStatusLabel.Text   = "Connecting ...";
            connected = true;

            lua = new Lua(luaScript);

            backgroundWorker.RunWorkerAsync();
        }
コード例 #2
0
        private void disconnect2()
        {
            VJoy1.Release();
            VJoy2.Release();
            try {
                serialReader.ClosePort();
            } catch (Exception) {}

            ActiveChannels              = 0;
            comboProtocol.Enabled       = true;
            comboPorts.Enabled          = true;
            buttonPortSetup.Enabled     = true;
            buttonPortsRefresh.Enabled  = true;
            buttonProtocolSetup.Enabled = true;
            buttonConnect.Text          = "Connect";
            connected = false;
            toolStripStatusLabel.Text = "Disconnected";
            comboJoysticks1.Enabled   = true;
            comboJoysticks2.Enabled   = true;
        }