public void Init(InputMappingController controller, int index) { this.controller = controller; this.index = index; key = controller.currentCompoundKeys[index]; RefreshDisplay(); }
public CompoundKey(CompoundKey key) { Ctrl = key.Ctrl; Win = key.Win; Alt = key.Alt; Shift = key.Shift; Key = key.Key; }
/// <summary> /// Parse CompoundKey from string. Keys should separated by '+' and any token except Ctrl, Win, Alt, Shift /// should be the name of KeyCode /// </summary> /// <param name="str">the string to parse</param> /// <exception cref="ArgumentNullException">argument is null</exception> /// <exception cref="ArgumentException">argument is ill formed</exception> /// <returns></returns> public static CompoundKey FromString(string str) { if (str == null) { throw new ArgumentNullException(); } var v = new CompoundKey(); var keys = str.Split('+').Select(k => k.Trim()); foreach (var key in keys) { switch (key) { case "Ctrl": v.Ctrl = true; break; case "Win": v.Win = true; break; case "Alt": v.Alt = true; break; case "Shift": v.Shift = true; break; default: v.Key = (KeyCode)Enum.Parse(typeof(KeyCode), key); break; } } return(v); }