public KeymapConnectionRow(KeymapInput input, KeymapOutConfig config, bool fromDefault)
        {
            InitializeComponent();
            this.input = input;
            this.config = config;
            this.fromDefault = fromDefault;

            this.connection_input_name.Text = input.Name;
            if (input.Continous)
            {
                this.stickBlup.Visibility = Visibility.Visible;
                this.rAdd.Visibility = Visibility.Collapsed;
            }
            else if (input.Cursor)
            {
                this.cursorBlup.Visibility = Visibility.Visible;
                this.rAdd.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.buttonBlup.Visibility = Visibility.Visible;
            }

            this.SetConfig(config);
        }
        public KeymapConnectionRow(KeymapInput input, KeymapOutConfig config, bool fromDefault)
        {
            InitializeComponent();
            this.input = input;
            this.config = config;
            this.fromDefault = fromDefault;

            this.connection_input_name.Text = input.Name;
            if (input.Continous)
            {
                this.stickBlup.Visibility = Visibility.Visible;
                this.rAdd.Visibility = Visibility.Collapsed;
            }
            else if (input.Cursor)
            {
                this.cursorBlup.Visibility = Visibility.Visible;
                this.rAdd.Visibility = Visibility.Collapsed;
            }
            else
            {
                this.buttonBlup.Visibility = Visibility.Visible;
            }

            this.connection_input_config_border.Visibility = Visibility.Collapsed;
            this.connection_input_config_closebutton.Visibility = Visibility.Hidden;
            if(this.input.Continous)
            {
                this.deadzone_updown.Value = this.config.Deadzone;
                this.scale_updown.Value = this.config.Scale;
                this.threshold_updown.Value = this.config.Threshold;
            }
            else
            {
                this.connection_input_config_openbutton.Visibility = Visibility.Hidden;
            }

            this.SetConfig(config);
        }
 private void connectionRow_OnConfigChanged(KeymapInput input, KeymapOutConfig config)
 {
     this.currentKeymap.setConfigFor(this.selectedWiimote, input, config);
     if (OnConfigChanged != null)
     {
         OnConfigChanged();
     }
 }
Exemplo n.º 4
0
        public void setConfigFor(int controllerId, KeymapInput input, KeymapOutConfig config)
        {
            string key;
            if (controllerId == 0)
            {
                key = "All";
            }
            else
            {
                key = "" + controllerId;
            }

            {
                JToken level1 = this.jsonObj.GetValue(key);
                if (level1 == null || level1.Type != JTokenType.Object)
                {
                    jsonObj.Add(key,new JObject());
                }
                level1 = this.jsonObj.GetValue(key);
                JToken level2 = ((JObject)level1).GetValue(input.Key);
                if (level2 != null)
                {
                    ((JObject)level1).Remove(input.Key);
                }

                if (config.Stack.Count > 1)
                {
                    JArray array = new JArray();
                    foreach(KeymapOutput output in config.Stack)
                    {
                        array.Add(output.Key);
                    }
                    ((JObject)level1).Add(input.Key, array);
                }
                else if (config.Stack.Count == 1)
                {
                    ((JObject)level1).Add(input.Key, config.Stack.First().Key);
                }

                jsonObj.Remove(key);
                jsonObj.Add(key, level1);
            }
            save();
        }
Exemplo n.º 5
0
        public void setConfigFor(int controllerId, KeymapInput input, KeymapOutConfig config)
        {
            string key;
            if (controllerId == 0)
            {
                key = "All";
            }
            else
            {
                key = "" + controllerId;
            }

            {
                JToken level1 = this.jsonObj.GetValue(key);
                if (level1 == null || level1.Type != JTokenType.Object)
                {
                    jsonObj.Add(key,new JObject());
                }
                level1 = this.jsonObj.GetValue(key);
                JToken level2 = ((JObject)level1).GetValue(input.Key);
                if (level2 != null)
                {
                    ((JObject)level1).Remove(input.Key);
                }

                if (!config.Inherited)
                {
                    JToken outputs = null;

                    if (config.Stack.Count > 1)
                    {
                        JArray array = new JArray();
                        foreach (KeymapOutput output in config.Stack)
                        {
                            array.Add(output.Key);
                        }
                        outputs = array;
                    }
                    else if (config.Stack.Count == 1)
                    {
                        outputs = config.Stack.First().Key;
                    }

                    if (config.Scale != Settings.Default.defaultContinousScale || config.Threshold != Settings.Default.defaultContinousPressThreshold || config.Deadzone != Settings.Default.defaultContinousDeadzone)
                    {
                        JObject settings = new JObject();
                        if (config.Scale != Settings.Default.defaultContinousScale)
                        {
                            settings.Add("scale", config.Scale);
                        }
                        if (config.Threshold != Settings.Default.defaultContinousPressThreshold)
                        {
                            settings.Add("threshold", config.Threshold);
                        }
                        if (config.Deadzone != Settings.Default.defaultContinousDeadzone)
                        {
                            settings.Add("deadzone", config.Deadzone);
                        }
                        settings.Add("output", outputs);
                        outputs = settings;
                    }

                    ((JObject)level1).Add(input.Key, outputs);
                }
                jsonObj.Remove(key);
                jsonObj.Add(key, level1);
            }
            save();
        }