public static void AddMouseInput(FpsInput input, int mouseButton) { if (s_mouseInputs.ContainsKey(input)) { s_mouseInputs[input] = mouseButton; } else { s_mouseInputs.Add(input, mouseButton); } }
public static void AddKeyboardInput(FpsInput input, KeyCode key) { if (s_keyboardInputs.TryGetValue(input, out s_keysToCheck) == false) { s_keyboardInputs.Add(input, new HashSet <KeyCode>() { key }); } else { s_keysToCheck.Add(key); } }
public static KeyCode GetKeyboardInput(FpsInput input) { if (s_keyboardInputs.TryGetValue(input, out s_keysToCheck)) { KeyCode value = KeyCode.Question; // get the first thing we find and exit the loop foreach (KeyCode code in s_keysToCheck) { value = code; break; } return(value); } Debug.LogWarningFormat("FpsControl.GetKeyboardInput: No entry found for FpsInput.{0}", input.ToString()); return(KeyCode.Question); }
public static bool WasReleasedThisFrame(FpsInput input) { int mouseButton = 0; if (s_mouseInputs.TryGetValue(input, out mouseButton) && Input.GetMouseButtonUp(mouseButton)) { return(true); } if (s_keyboardInputs.TryGetValue(input, out s_keysToCheck)) { foreach (KeyCode key in s_keysToCheck) { if (Input.GetKeyUp(key)) { return(true); } } } return(false); }
public static bool IsPressed(FpsInput input) { int mouseButton = 0; if (s_mouseInputs.TryGetValue(input, out mouseButton) && Input.GetMouseButton(mouseButton)) { return(true); } if (s_keyboardInputs.TryGetValue(input, out s_keysToCheck)) { foreach (KeyCode key in s_keysToCheck) { if (Input.GetKey(key)) { return(true); } } } return(false); }