public void Save() { Log.Info("Saving keyboard mappings"); try { var keyboardMappings = new KeyboardMappings(); foreach (var command in _commandManager.GetCommands()) { var keyboardMapping = new KeyboardMapping(); keyboardMapping.CommandName = command; keyboardMapping.InputGesture = _commandManager.GetInputGesture(command); keyboardMappings.Mappings.Add(keyboardMapping); } using (var fileStream = _fileService.Create(_fileName)) { _xmlSerializer.Serialize(keyboardMappings, fileStream, null); } } catch (Exception ex) { Log.Error(ex, "Failed to save the keyboard mappings"); } }
void Start() { m_presets = new List <PresetData>(); // parse the m_presets Debug.LogFormat("Loading {0}", mappingsFileName()); FileInfo theSourceFile = new FileInfo(mappingsFileName()); StreamReader reader = theSourceFile.OpenText(); string text; do { text = reader.ReadLine(); KeyboardMapping p = JsonUtility.FromJson <KeyboardMapping>(text); if (p != null) { m_controllers.Add(p); } Debug.Log(text); } while (text != null); Debug.LogFormat("Loading {0}", presetFileName()); theSourceFile = new FileInfo(presetFileName()); reader = theSourceFile.OpenText(); do { text = reader.ReadLine(); PresetData p = JsonUtility.FromJson <PresetData>(text); m_presets.Add(p); Debug.Log(text); } while (text != null); Next(); }
public static void Initialize(ContentManager contentManager) { foreach (string line in File.ReadAllLines(contentManager.RootDirectory + "/KeyboardMapping.txt")) { string[] parts = line.Split(':'); KeyboardMapping.Add((InputButton)ResourceManager.ParseItemData <InputButton>(parts[0]), (Keys)ResourceManager.ParseItemData <Keys>(parts[1])); } GamePadUsedLast = false; }
public TheMatrixKeyboard IsNavigatingFrom(char FromCharacter) { //ignore from when it starts with a space. will continue from last character if (FromCharacter != ' ') { KeyboardMapping.TryGetValue(FromCharacter, out startIndex); } return(this); }
public void GetUnmappedKey() { // Setup KeyboardMapping mapping = new KeyboardMapping(); // Verify byte?key = mapping.GetKey(Key.A); Assert.IsFalse(key.HasValue); }
private void CheckForChampionUpdate(Color[,] colors) { var keyRow = KeyboardMapping.GetHiByte((int)RZKeys.RZKEY_W); var keyColumn = KeyboardMapping.GetLowByte((int)RZKeys.RZKEY_W); var colour = colors[keyRow, keyColumn]; var champ = ChampionColours.GetChampion(colour); if (champ.HasValue) { OnChampionUpdate?.Invoke(champ.Value); } }
public void MapAndGetKey() { // Setup KeyboardMapping mapping = new KeyboardMapping(); // Act mapping.Map(Key.A, CPvC.Keys.A); // Verify byte?key = mapping.GetKey(Key.A); Assert.IsTrue(key.HasValue); Assert.AreEqual(CPvC.Keys.A, key.Value); }
public string To(char ToCharacter) { //this action will return the string of commands which navigate from start index to end index string result = ""; if (ToCharacter == ' ') { result = "S"; } else { //turn the char into an index to compare KeyboardMapping.TryGetValue(ToCharacter, out endIndex); result = NavigateMatrix(); } return(result); }
private void Start() { KeyboardMapping StandardKeyboardMapping = new KeyboardMapping(); StandardKeyboardMapping.MapBindings(-1); StandardKeyboardMapping.OriginalIndex = -1; this.PlayerMappings.Add(StandardKeyboardMapping); this.FillNameToInputMappingLookupTable(); var devices = Input.GetJoystickNames(); for (int i = 0; i < devices.Length; i++) { if (!string.IsNullOrEmpty(devices[i])) { Type typeofInput; if (this.NameToInputMappingLookupTable.TryGetValue(devices[i], out typeofInput)) { InputMapping instance = (InputMapping)Activator.CreateInstance(typeofInput); instance.OriginalIndex = i; instance.MapBindings(i + 1); this.PlayerMappings.Add(instance); } else { Debug.Log("Unknown controller device, pray it works as Xbox input"); Xbox360Mapping mapping = new Xbox360Mapping(); mapping.OriginalIndex = i; mapping.MapBindings(i + 1); this.PlayerMappings.Add(mapping); } } } this.StartCoroutine(this.CheckForNewControllersCoroutine()); this.StartCoroutine(this.CheckForControllerDC()); }
public KeyboardPlayerInput(KeyboardMapping mapping) { this.mapping = mapping; this.mapping.ToString(); // Suppress warning... }
public void InitKeyboardMap() { _keyMap = new KeyboardMapping(); _keyMap.Map(Key.A, Keys.A); _keyMap.Map(Key.B, Keys.B); _keyMap.Map(Key.C, Keys.C); _keyMap.Map(Key.D, Keys.D); _keyMap.Map(Key.E, Keys.E); _keyMap.Map(Key.F, Keys.F); _keyMap.Map(Key.G, Keys.G); _keyMap.Map(Key.H, Keys.H); _keyMap.Map(Key.I, Keys.I); _keyMap.Map(Key.J, Keys.J); _keyMap.Map(Key.K, Keys.K); _keyMap.Map(Key.L, Keys.L); _keyMap.Map(Key.M, Keys.M); _keyMap.Map(Key.N, Keys.N); _keyMap.Map(Key.O, Keys.O); _keyMap.Map(Key.P, Keys.P); _keyMap.Map(Key.Q, Keys.Q); _keyMap.Map(Key.R, Keys.R); _keyMap.Map(Key.S, Keys.S); _keyMap.Map(Key.T, Keys.T); _keyMap.Map(Key.U, Keys.U); _keyMap.Map(Key.V, Keys.V); _keyMap.Map(Key.W, Keys.W); _keyMap.Map(Key.X, Keys.X); _keyMap.Map(Key.Y, Keys.Y); _keyMap.Map(Key.Z, Keys.Z); _keyMap.Map(Key.D0, Keys.Num0); _keyMap.Map(Key.D1, Keys.Num1); _keyMap.Map(Key.D2, Keys.Num2); _keyMap.Map(Key.D3, Keys.Num3); _keyMap.Map(Key.D4, Keys.Num4); _keyMap.Map(Key.D5, Keys.Num5); _keyMap.Map(Key.D6, Keys.Num6); _keyMap.Map(Key.D7, Keys.Num7); _keyMap.Map(Key.D8, Keys.Num8); _keyMap.Map(Key.D9, Keys.Num9); _keyMap.Map(Key.Escape, Keys.Escape); _keyMap.Map(Key.Tab, Keys.Tab); _keyMap.Map(Key.CapsLock, Keys.CapsLock); _keyMap.Map(Key.LeftShift, Keys.Shift); _keyMap.Map(Key.RightShift, Keys.Shift); _keyMap.Map(Key.LeftCtrl, Keys.Control); _keyMap.Map(Key.LeftAlt, Keys.Copy); _keyMap.Map(Key.Up, Keys.CursorUp); _keyMap.Map(Key.Down, Keys.CursorDown); _keyMap.Map(Key.Left, Keys.CursorLeft); _keyMap.Map(Key.Right, Keys.CursorRight); _keyMap.Map(Key.OemOpenBrackets, Keys.LeftBrace); _keyMap.Map(Key.OemCloseBrackets, Keys.RightBrace); _keyMap.Map(Key.OemSemicolon, Keys.Asterix); _keyMap.Map(Key.OemQuotes, Keys.Plus); _keyMap.Map(Key.OemMinus, Keys.EqualsSign); _keyMap.Map(Key.OemPipe, Keys.At); _keyMap.Map(Key.OemPlus, Keys.Caret); _keyMap.Map(Key.Back, Keys.Delete); _keyMap.Map(Key.NumPad0, Keys.Function0); _keyMap.Map(Key.NumPad1, Keys.Function1); _keyMap.Map(Key.NumPad2, Keys.Function2); _keyMap.Map(Key.NumPad3, Keys.Function3); _keyMap.Map(Key.NumPad4, Keys.Function4); _keyMap.Map(Key.NumPad5, Keys.Function5); _keyMap.Map(Key.NumPad6, Keys.Function6); _keyMap.Map(Key.NumPad7, Keys.Function7); _keyMap.Map(Key.NumPad8, Keys.Function8); _keyMap.Map(Key.NumPad9, Keys.Function9); _keyMap.Map(Key.Enter, Keys.Return); _keyMap.Map(Key.Space, Keys.Space); _keyMap.Map(Key.OemComma, Keys.LessThan); _keyMap.Map(Key.OemPeriod, Keys.GreaterThan); //_keyMap.Map(Key.NumPad4, Keys.Joy0Left); //_keyMap.Map(Key.NumPad6, Keys.Joy0Right); //_keyMap.Map(Key.NumPad8, Keys.Joy0Up); //_keyMap.Map(Key.NumPad2, Keys.Joy0Down); //_keyMap.Map(Key.NumPad0, Keys.Joy0Fire2); //_keyMap.Map(Key.NumPad5, Keys.Joy0Fire1); }