/// <summary> /// Add a new input axis slot to the action register /// </summary> /// <param name="input">The input axis to add</param> /// <returns>True if the action was succesfully added, false if the input was already added</returns> public bool AddInputAxis(string input) { foreach (ControllerActionSerialized cas in actionRegisterSerialized) { if (cas.input == input) { return(false); } } ControllerActionSerialized newCas = new ControllerActionSerialized(); newCas.input = input; actionRegisterSerialized.Add(newCas); return(true); }
/// <summary> /// Remove an input axis slot from the register /// </summary> /// <param name="input">The input axis to remove</param> public void RemoveInputAxis(string input) { ControllerActionSerialized toRemove = new ControllerActionSerialized(); bool found = false; foreach (ControllerActionSerialized cas in actionRegisterSerialized) { if (cas.input == input) { toRemove = cas; found = true; break; } } if (found) { actionRegisterSerialized.Remove(toRemove); } }
/// <summary> /// Changes an input key and keeps associated actions /// </summary> /// <param name="from">The input axis to change</param> /// <param name="to">New name for the input axis</param> public bool ChangeInputAxis(string from, string to) { int index = -1; foreach (ControllerActionSerialized cas in actionRegisterSerialized) { if (cas.input == from) { index = actionRegisterSerialized.IndexOf(cas); break; } } if (index != -1) { ControllerActionSerialized cas = actionRegisterSerialized[index]; cas.input = to; actionRegisterSerialized[index] = cas; return(true); } return(false); }