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); }
private void connectionRow_OnConfigChanged(KeymapInput input, KeymapOutConfig config) { this.currentKeymap.setConfigFor(this.selectedWiimote, input, config); if (OnConfigChanged != null) { OnConfigChanged(); } }
public void SetConfig(KeymapOutConfig config) { this.config = config; //this.connection_output_name.Text = config.Output.Name; this.connection_output_stack.Children.Clear(); for(int i=0; i<config.Stack.Count; i++) { KeymapOutput output = config.Stack[i]; KeymapOutputItem item = new KeymapOutputItem(output); item.AllowDrop = true; item.OnDragStart += item_OnDragStart; item.OnDragStop += item_OnDragStop; item.Drop += output_Drop; item.DragEnter += output_DragEnter; item.DragLeave += output_DragLeave; item.Tag = i; this.connection_output_stack.Children.Add(item); } if (config.Inherited) { this.connection_output_stack.Opacity = 0.6; this.rAdd.Visibility = Visibility.Hidden; this.rClear.Visibility = Visibility.Hidden; } else { this.connection_output_stack.Opacity = 1.0; this.rAdd.Visibility = Visibility.Visible; this.rClear.Visibility = Visibility.Visible; } /* if (config.Inherited) { Color color = KeymapColors.GetColor(config.Output.Type); color.A = 60; this.connection_output_border.Background = new SolidColorBrush(color); this.rClear.Visibility = Visibility.Hidden; } else { this.connection_output_border.Background = new SolidColorBrush(KeymapColors.GetColor(config.Output.Type)); this.rClear.Visibility = Visibility.Visible; } */ /*if (fromDefault) { this.rClear.Visibility = Visibility.Hidden; }*/ if (OnConfigChanged != null) { OnConfigChanged(this.input,this.config); } }
public void SetConfig(KeymapOutConfig config) { this.config = config; //this.connection_output_name.Text = config.Output.Name; this.connection_output_stack.Children.Clear(); for (int i = 0; i < config.Stack.Count; i++) { KeymapOutput output = config.Stack[i]; KeymapOutputItem item = new KeymapOutputItem(output); item.AllowDrop = true; item.OnDragStart += item_OnDragStart; item.OnDragStop += item_OnDragStop; item.Drop += output_Drop; item.DragEnter += output_DragEnter; item.DragLeave += output_DragLeave; item.Tag = i; this.connection_output_stack.Children.Add(item); } if (config.Inherited) { this.connection_output_stack.Opacity = 0.6; this.rAdd.Visibility = Visibility.Hidden; this.rClear.Visibility = Visibility.Hidden; } else { this.connection_output_stack.Opacity = 1.0; this.rAdd.Visibility = Visibility.Visible; this.rClear.Visibility = Visibility.Visible; } /* * if (config.Inherited) * { * Color color = KeymapColors.GetColor(config.Output.Type); * color.A = 60; * this.connection_output_border.Background = new SolidColorBrush(color); * this.rClear.Visibility = Visibility.Hidden; * } * else * { * this.connection_output_border.Background = new SolidColorBrush(KeymapColors.GetColor(config.Output.Type)); * this.rClear.Visibility = Visibility.Visible; * } */ /*if (fromDefault) * { * this.rClear.Visibility = Visibility.Hidden; * }*/ if (OnConfigChanged != null) { OnConfigChanged(this.input, this.config); } }
private void appendConnectionList(List <KeymapInput> list, Keymap keymap, int wiimote, bool defaultKeymap, Panel container) { foreach (KeymapInput input in list) { KeymapOutConfig config = keymap.getConfigFor(wiimote, input.Key); if (config != null) { KeymapConnectionRow row = new KeymapConnectionRow(input, config, defaultKeymap); row.OnConfigChanged += connectionRow_OnConfigChanged; row.OnDragStart += output_OnDragStart; row.OnDragStop += output_OnDragStop; container.Children.Add(row); } } }
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(); }
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); }
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); }
//0 = all public KeymapOutConfig getConfigFor(int controllerId, string input) { string key; if (controllerId > 0) { key = "" + controllerId; } else { key = "All"; } JToken level1 = this.jsonObj.GetValue(key); if (level1 != null && level1.Type == JTokenType.Object) { JToken level2 = ((JObject)level1).GetValue(input); if (level2 != null) { if (level2.Type == JTokenType.String) { if (KeymapDatabase.Current.getOutput(level2.ToString().ToLower()) != null) { return(new KeymapOutConfig(KeymapDatabase.Current.getOutput(level2.ToString().ToLower()), false)); } } else if (level2.Type == JTokenType.Array) { JArray array = (JArray)level2; List <KeymapOutput> result = new List <KeymapOutput>(); foreach (JValue value in array) { if (KeymapDatabase.Current.getOutput(value.ToString().ToLower()) != null) { result.Add(KeymapDatabase.Current.getOutput(value.ToString().ToLower())); } } if (result.Count == array.Count) { return(new KeymapOutConfig(result, false)); } } } } if (controllerId > 0) { //If we are searching for controller-specific keymaps we can inherit from the "All" setting. KeymapOutConfig result = this.getConfigFor(0, input); if (result != null) { result.Inherited = true; } return(result); } //If we can not find any setting in the All group, search for inherit from the default keymap if (this.Parent != null) { KeymapOutConfig result = this.Parent.getConfigFor(controllerId, input); if (result != null) { result.Inherited = true; } return(result); } else { //This will happen if we request a input string that is not defined in this nor the default keymap. return(null); } }
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(); }
//0 = all public KeymapOutConfig getConfigFor(int controllerId, string input) { string key; if (controllerId > 0) { key = "" + controllerId; } else { key = "All"; } JToken level1 = this.jsonObj.GetValue(key); if (level1 != null && level1.Type == JTokenType.Object) { JToken level2 = ((JObject)level1).GetValue(input); if (level2 != null) { if (level2.Type == JTokenType.String) { if (KeymapDatabase.Current.getOutput(level2.ToString().ToLower()) != null) { return new KeymapOutConfig(KeymapDatabase.Current.getOutput(level2.ToString().ToLower()), false); } } else if (level2.Type == JTokenType.Array) { JArray array = (JArray)level2; List<KeymapOutput> result = new List<KeymapOutput>(); foreach (JValue value in array) { if (KeymapDatabase.Current.getOutput(value.ToString().ToLower()) != null) { result.Add(KeymapDatabase.Current.getOutput(value.ToString().ToLower())); } } if (result.Count == array.Count) { return new KeymapOutConfig(result, false); } } else if (level2.Type == JTokenType.Object) { JToken level3 = ((JObject)level2).GetValue("output"); if (level3 != null) { KeymapOutConfig outconfig = null; if (level3.Type == JTokenType.String) { if (KeymapDatabase.Current.getOutput(level3.ToString().ToLower()) != null) { outconfig = new KeymapOutConfig(KeymapDatabase.Current.getOutput(level3.ToString().ToLower()), false); } } else if (level3.Type == JTokenType.Array) { JArray array = (JArray)level3; List<KeymapOutput> result = new List<KeymapOutput>(); foreach (JValue value in array) { if (KeymapDatabase.Current.getOutput(value.ToString().ToLower()) != null) { result.Add(KeymapDatabase.Current.getOutput(value.ToString().ToLower())); } } if (result.Count == array.Count) { outconfig = new KeymapOutConfig(result, false); } } if (outconfig != null) { if (((JObject)level2).GetValue("scale") != null && ((JObject)level2).GetValue("scale").Type == JTokenType.Float) { outconfig.Scale = Double.Parse(((JObject)level2).GetValue("scale").ToString()); } if (((JObject)level2).GetValue("threshold") != null && ((JObject)level2).GetValue("threshold").Type == JTokenType.Float) { outconfig.Threshold = Double.Parse(((JObject)level2).GetValue("threshold").ToString()); } if (((JObject)level2).GetValue("deadzone") != null && ((JObject)level2).GetValue("deadzone").Type == JTokenType.Float) { outconfig.Deadzone = Double.Parse(((JObject)level2).GetValue("deadzone").ToString()); } return outconfig; } } } } } if(controllerId > 0) { //If we are searching for controller-specific keymaps we can inherit from the "All" setting. KeymapOutConfig result = this.getConfigFor(0, input); if (result != null) { result.Inherited = true; } return result; } //If we can not find any setting in the All group, search for inherit from the default keymap if (this.Parent != null) { KeymapOutConfig result = this.Parent.getConfigFor(controllerId, input); if (result != null) { result.Inherited = true; } return result; } else { //This means we have no setting for the input on this keymap nor any keymap to inherit from. Let's save a "Disable" setting on this. this.setConfigFor(controllerId, KeymapDatabase.Current.getInput(input), new KeymapOutConfig(KeymapDatabase.Current.getDisableOutput(),false)); //It's a small chance of deadlock here if the above command doesnt work, but wth return this.getConfigFor(controllerId,input); } }
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(); }
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(); }
//0 = all public KeymapOutConfig getConfigFor(int controllerId, string input) { string key; if (controllerId > 0) { key = "" + controllerId; } else { key = "All"; } JToken level1 = this.jsonObj.GetValue(key); if (level1 != null && level1.Type == JTokenType.Object) { JToken level2 = ((JObject)level1).GetValue(input); if (level2 != null) { if (level2.Type == JTokenType.String) { if (KeymapDatabase.Current.getOutput(level2.ToString().ToLower()) != null) { return(new KeymapOutConfig(KeymapDatabase.Current.getOutput(level2.ToString().ToLower()), false)); } } else if (level2.Type == JTokenType.Array) { JArray array = (JArray)level2; List <KeymapOutput> result = new List <KeymapOutput>(); foreach (JValue value in array) { if (KeymapDatabase.Current.getOutput(value.ToString().ToLower()) != null) { result.Add(KeymapDatabase.Current.getOutput(value.ToString().ToLower())); } } if (result.Count == array.Count) { return(new KeymapOutConfig(result, false)); } } else if (level2.Type == JTokenType.Object) { JToken level3 = ((JObject)level2).GetValue("output"); if (level3 != null) { KeymapOutConfig outconfig = null; if (level3.Type == JTokenType.String) { if (KeymapDatabase.Current.getOutput(level3.ToString().ToLower()) != null) { outconfig = new KeymapOutConfig(KeymapDatabase.Current.getOutput(level3.ToString().ToLower()), false); } } else if (level3.Type == JTokenType.Array) { JArray array = (JArray)level3; List <KeymapOutput> result = new List <KeymapOutput>(); foreach (JValue value in array) { if (KeymapDatabase.Current.getOutput(value.ToString().ToLower()) != null) { result.Add(KeymapDatabase.Current.getOutput(value.ToString().ToLower())); } } if (result.Count == array.Count) { outconfig = new KeymapOutConfig(result, false); } } if (outconfig != null) { if (((JObject)level2).GetValue("scale") != null && ((JObject)level2).GetValue("scale").Type == JTokenType.Float) { outconfig.Scale = Double.Parse(((JObject)level2).GetValue("scale").ToString()); } if (((JObject)level2).GetValue("threshold") != null && ((JObject)level2).GetValue("threshold").Type == JTokenType.Float) { outconfig.Threshold = Double.Parse(((JObject)level2).GetValue("threshold").ToString()); } if (((JObject)level2).GetValue("deadzone") != null && ((JObject)level2).GetValue("deadzone").Type == JTokenType.Float) { outconfig.Deadzone = Double.Parse(((JObject)level2).GetValue("deadzone").ToString()); } return(outconfig); } } } } } if (controllerId > 0) { //If we are searching for controller-specific keymaps we can inherit from the "All" setting. KeymapOutConfig result = this.getConfigFor(0, input); if (result != null) { result.Inherited = true; } return(result); } //If we can not find any setting in the All group, search for inherit from the default keymap if (this.Parent != null) { KeymapOutConfig result = this.Parent.getConfigFor(controllerId, input); if (result != null) { result.Inherited = true; } return(result); } else { //This means we have no setting for the input on this keymap nor any keymap to inherit from. Let's save a "Disable" setting on this. this.setConfigFor(controllerId, KeymapDatabase.Current.getInput(input), new KeymapOutConfig(KeymapDatabase.Current.getDisableOutput(), false)); //It's a small chance of deadlock here if the above command doesnt work, but wth return(this.getConfigFor(controllerId, input)); } }