private static bool IsActionMapTriggered(ActionMap actionMap) { for (int i = 0; i < actionMap.keyboardKeys.Count; i++) { if (IsKeyTriggered(actionMap.keyboardKeys[i])) { return(true); } } if (currentGamePadState.IsConnected) { for (int i = 0; i < actionMap.gamePadButtons.Count; i++) { if (IsGamePadButtonTriggered(actionMap.gamePadButtons[i])) { return(true); } } } return(false); }
/// <summary> /// Reset the action mapping to the defualts /// </summary> private static void ResetActionMaps() { //Try Load config var jsonRead = FileSystem.ReadTextLocalStorage("Input.json").Result; actionMaps = JsonConvert.DeserializeObject <SortedDictionary <string, ActionMap> >(jsonRead); if (actionMaps == null) { actionMaps = new SortedDictionary <string, ActionMap>(); //actionMap //move up var actionMap = new ActionMap(); actionMap.AddKeyboardKeyMap(Keys.W); actionMap.AddKeyboardKeyMap(Keys.Up); actionMap.AddGamePadMap(GamePadButtons.Up); actionMaps.Add("MoveUp", actionMap); var json = JsonConvert.SerializeObject(actionMaps); FileSystem.WriteTextLocalStorage("Input.json", json).Wait(); } }
private static bool IsActionMapPressed(ActionMap actionMap) { for (int i = 0; i < actionMap.keyboardKeys.Count; i++) { if (IsKeyPressed(actionMap.keyboardKeys[i])) { return(true); } } //Is a Gamepad pugged in? if (currentGamePadState.IsConnected) { for (int i = 0; i < actionMap.gamePadButtons.Count; i++) { if (IsGamePadButtonPressed(actionMap.gamePadButtons[i])) { return(true); } } } return(false); }