public void Merge(KeyMap newMap) { foreach (VirtualKey key in newMap._map.Keys) { if (!_map.ContainsKey(key)) { _map.Add(key, new List <KeyProperty>()); } _map[key].AddRange(newMap._map[key]); } }
public static KeyMap JsonToKeyMap(string jsonString) { //Debug.Log(jsonString); JSONNode config = JSON.Parse(jsonString); KeyMap deviceMap = new KeyMap(); //iterate through all virtualkeys foreach (string virtualKeyName in config.AsObject.Keys) { IEnumerable <JSONNode> hardKeys = config[virtualKeyName].Children; VirtualKey vKey = VirtualKey.NONE; try { vKey = (VirtualKey)Enum.Parse(typeof(VirtualKey), virtualKeyName); } catch (ArgumentException) { return(null); } //iterate all hardkeys assigned to a virtual key foreach (JSONNode hardKey in hardKeys) { string keyName = hardKey["KeyName"].Value; bool isAxis = hardKey["IsAxis"] != null ? hardKey["IsAxis"].AsBool : false; bool invert = hardKey["Inverted"] != null ? hardKey["Inverted"].AsBool : false; string condValue = hardKey["KeyTriggerCondition"]; string orientValue = hardKey["AxisOrientation"]; KeyTriggerCondition condition = KeyTriggerCondition.NON_ZERO; if (condValue != null) { try { condition = (KeyTriggerCondition)Enum.Parse(typeof(KeyTriggerCondition), condValue); } catch (ArgumentException) {} } AxisOrientation orientation = AxisOrientation.NONE; if (orientValue != null) { try { orientation = (AxisOrientation)Enum.Parse(typeof(AxisOrientation), orientValue); } catch (ArgumentException) {} } KeyProperty property = new KeyProperty(keyName, isAxis, invert, condition, orientation); deviceMap.AddKeyBind(vKey, property); } } return(deviceMap); }
public static Dictionary <string, KeyMap> JsonToKeyConfiguration(string jsonString) { JSONNode configs = JSON.Parse(jsonString); Dictionary <string, KeyMap> mapping = new Dictionary <string, KeyMap>(); foreach (string configName in configs.AsObject.Keys) { KeyMap deviceMap = JsonToKeyMap(configs[configName].ToString()); mapping.Add(configName, deviceMap); // Debug.Log("Created keymap with "+deviceMap._map.Count +" elements"); } return(mapping); }
public AbstractController(KeyMap keymap, string name, int number) { //Debug.Log("Created joystick "+number+": "+name); Name = name; Number = number; Inverted = false; Sensibility = 1; //DeadZone = 0.25f; _keymap = new KeyMap(); if (keymap != null) { _keymap = keymap; } }
public KeyboardController(KeyMap keymap, int number) : base(keymap, "Keyboard", number) { }
public void Remap(KeyMap newMap) { _map = DeepCopyDictionary(newMap._map); }
public ConsoleController(KeyMap keymap, string name, int number) : base(keymap, name, number) { suffix = "J" + number + " "; }
public ConsoleController(KeyMap keymap, string name) : this(keymap, name, 0) { }