예제 #1
0
 private void resetProfile()
 {
     // reset profile
     loadProfile(new Configuration.Profile());
     comboProfiles.Text = config.DefaultProfile = "";
     currentProfile     = buildProfile();
 }
예제 #2
0
        void ButtonSaveProfileClick(object sender, EventArgs e)
        {
            string name = comboProfiles.Text.Trim();

            if (name.Length == 0)
            {
                MessageBox.Show("Enter a profile name");
                return;
            }

            var p = new Configuration.Profile();

            p.Protocol     = comboProtocol.SelectedIndex;
            p.COMPort      = comboPorts.Text;
            p.BaudRate     = textBaud.Text;
            p.VJoyInstance = comboJoysticks.Text;

            p.Mappings = new List <Mapping>();

            foreach (var m in mappings)
            {
                p.Mappings.Add(m.Copy());
            }

            config.PutProfile(name, p);
            config.DefaultProfile = name;
            config.Save();

            reloadProfiles();
        }
예제 #3
0
        private void loadProfile(Configuration.Profile p)
        {
            lua = null;

            while (mappings.Count > 0)
            {
                mappings[0].Remove();
            }

            if (!connected)
            {
                // load this stuff only if not connected
                comboProtocol.SelectedIndex = p.Protocol < comboProtocol.Items.Count ? p.Protocol : 0;
                comboPorts.SelectedItem     = p.COMPort;
                if (comboPorts.SelectedItem == null && comboPorts.Items.Count > 0)
                {
                    comboPorts.SelectedIndex = 0;
                }
                useCustomSerialParameters    = p.UseCustomSerialParameters;
                serialParameters             = p.SerialParameters;
                protocolConfig               = p.ProtocolConfiguration;
                comboJoysticks1.SelectedItem = p.VJoyInstance1;
                comboJoysticks2.SelectedItem = p.VJoyInstance2;
                if (comboJoysticks1.SelectedItem == null && comboJoysticks1.Items.Count > 0)
                {
                    comboJoysticks1.SelectedIndex = 0;
                }
                if (comboJoysticks2.SelectedItem == null && comboJoysticks2.Items.Count > 0)
                {
                    comboJoysticks2.SelectedIndex = 0;
                }
            }

            foreach (var m in p.Mappings)
            {
                addMapping(m.Copy());
            }

            failsafeUpdateRate = p.FailsafeUpdateRate;
            failsafeTime       = p.FailsafeTime;

            luaScript = p.LuaScript;
            lua       = new Lua(luaScript);

            setScriptButtonAndMenuText();

            currentProfile = p;
        }
예제 #4
0
        void ButtonSaveProfileClick(object sender, EventArgs e)
        {
            string name = comboProfiles.Text.Trim();

            if (name.Length == 0)
            {
                MessageBox.Show("Enter a profile name");
                return;
            }

            var p = buildProfile();

            config.PutProfile(name, p);
            config.DefaultProfile = name;
            config.Save();

            currentProfile = p;

            reloadProfiles();
        }
예제 #5
0
        private void loadProfile(Configuration.Profile p)
        {
            while (mappings.Count > 0)
            {
                mappings[0].Remove();
            }

            if (!connected)
            {
                // load this stuff only if not connected
                comboProtocol.SelectedIndex = p.Protocol;
                comboPorts.SelectedItem     = p.COMPort;
                textBaud.Text = p.BaudRate;
                comboJoysticks.SelectedItem = p.VJoyInstance;
            }

            foreach (var m in p.Mappings)
            {
                addMapping(m.Copy());
            }
        }
예제 #6
0
        private Configuration.Profile buildProfile()
        {
            var p = new Configuration.Profile();

            p.Protocol = comboProtocol.SelectedIndex;
            p.COMPort  = (string)comboPorts.SelectedItem;
            p.UseCustomSerialParameters = useCustomSerialParameters;
            p.SerialParameters          = serialParameters;
            p.ProtocolConfiguration     = protocolConfig;
            p.VJoyInstance       = comboJoysticks.Text;
            p.LuaScript          = luaScript;
            p.FailsafeUpdateRate = failsafeUpdateRate;
            p.FailsafeTime       = failsafeTime;

            p.Mappings = new List <Mapping>();

            foreach (var m in mappings)
            {
                p.Mappings.Add(m.Copy());
            }

            return(p);
        }