Ejemplo n.º 1
0
        static public axis fromJson(string json)
        {
            if (jsonParser == null)
            {
                jsonParser = new Regex("\"input\": \"(.*)\",.*" +
                                       "\"key\": \"(.*)\",.*" +
                                       "\"type\": \"(.*)\",.*" +
                                       "\"isKey\": \"(.*)\",.*" +
                                       "\"name\": \"(.*)\",.*" +
                                       "\"rest\": \"(.*)\"");
            }
            MatchCollection matches = jsonParser.Matches(json);
            GroupCollection groups  = matches[0].Groups;

            string   input  = groups[1].Value;
            int      ikey   = Int32.Parse(groups[2].Value);
            KeyCode  key    = (KeyCode)ikey;
            int      itype  = Int32.Parse(groups[3].Value);
            axisType type   = (axisType)itype;
            int      iIsKey = Int32.Parse(groups[4].Value);
            bool     isKey  = (iIsKey != 0);
            string   name   = groups[5].Value;
            float    rest   = float.Parse(groups[6].Value, CultureInfo.InvariantCulture);

            axis a = new axis();

            a.input = input;
            a.key   = key;
            a.type  = type;
            a.isKey = isKey;
            a.name  = name;
            a.rest  = rest;
            return(a);
        }
Ejemplo n.º 2
0
        public axis(KeyCode key)
        {
            this.key   = key;
            this.isKey = true;

            this.type  = axisType.none;
            this.input = "";

            this.name = $"Key: {this.key}";
        }
Ejemplo n.º 3
0
        private void initGamepad(string input, axisType type, float rest)
        {
            this.type  = type;
            this.input = input;
            this.isKey = false;
            this.rest  = rest;

            this.key = KeyCode.None;

            if (this.type == axisType.positiveAxis)
            {
                this.name = $"{this.input} +";
            }
            else if (this.type == axisType.negativeAxis)
            {
                this.name = $"{this.input} -";
            }
            else
            {
                this.name = this.input;
            }
        }
Ejemplo n.º 4
0
 public LFAxisInputMap(string _id, axisType _aType, KeyCode _keyNeg, KeyCode _keyPos, int _joystickNumber, int _joystickAxis)
 {
     id = _id;
     aType = _aType;
     keyPos = _keyPos;
     keyNeg = _keyNeg;
     joystickNumber = _joystickNumber;
     joystickAxis = _joystickAxis;
 }
Ejemplo n.º 5
0
 public axis(string input, axisType type)
 {
     this.initGamepad(input, type, 0.0f);
 }
Ejemplo n.º 6
0
 public axis(string input, axisType type, float rest)
 {
     this.initGamepad(input, type, rest);
 }