Пример #1
0
        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]);
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
 public KeyboardController(KeyMap keymap, int number) : base(keymap, "Keyboard", number)
 {
 }
Пример #6
0
 public void Remap(KeyMap newMap)
 {
     _map = DeepCopyDictionary(newMap._map);
 }
Пример #7
0
 public ConsoleController(KeyMap keymap, string name, int number) : base(keymap, name, number)
 {
     suffix = "J" + number + " ";
 }
Пример #8
0
 public ConsoleController(KeyMap keymap, string name) : this(keymap, name, 0)
 {
 }