/// <summary> /// Initializes a new instance of the <see cref="Reign.InputExButtonMap"/> class. /// </summary> /// <param name="type">Button Type.</param> /// <param name="player">Player input accepted.</param> /// <param name="name">Name from Unitys settings.</param> /// <param name="analogName">Analog name from Unitys settings.</param> /// <param name="analogPositive">Is analog button valid when value is positive.</param> public InputExButtonMap(ButtonTypes type, ControllerPlayers player, string name, string analogName, bool analogPositive) { this.Type = type; this.Player = player; this.Name = name; this.AnalogName = analogName; this.AnalogPositive = analogPositive; }
/// <summary> /// Gets if the button was let up /// </summary> /// <returns>Returns if valid or not</returns> /// <param name="type">Button Type.</param> /// <param name="player">Player input accepted.</param> public static bool GetButtonUp(ButtonTypes type, ControllerPlayers player) { InputExButtonMap mapping; string name = findButtonName(type, player, out mapping); if (mapping != null && mapping.analogUp) { return(true); } return(Input.GetButtonUp(name)); }
private static string findAnalogName(AnalogTypes type, ControllerPlayers player) { foreach (var map in AnalogMappings) { if (map.Type == type && map.Player == player) { return(map.Name); } } Debug.LogError(string.Format("Failed to find Analog {0} for Player {1}", type, player)); return("Unknown"); }
private static string findButtonName(ButtonTypes type, ControllerPlayers player, out InputExButtonMap mapping) { foreach (var map in ButtonMappings) { if (map.Type == type && map.Player == player) { mapping = map; return(map.Name); } } Debug.LogError(string.Format("Failed to find Button {0} for Player {1}", type, player)); mapping = null; return("Unknown"); }
/// <summary> /// Gets the Analog Axis value with no tolerance /// </summary> /// <returns>The axis.</returns> /// <param name="type">Analog Type.</param> /// <param name="player">Player input accepted.</param> public static float GetAxisRaw(AnalogTypes type, ControllerPlayers player) { return(Input.GetAxisRaw(findAnalogName(type, player))); }
/// <summary> /// Initializes a new instance of the <see cref="Reign.InputExAnalogMap"/> class. /// </summary> /// <param name="type">Analog Type.</param> /// <param name="player">Player input accepted.</param> /// <param name="name">Button name defined in Unitys settings.</param> public InputExAnalogMap(AnalogTypes type, ControllerPlayers player, string name) { this.Type = type; this.Player = player; this.Name = name; }
/// <summary> /// Initializes a new instance of the <see cref="Reign.InputExButtonMap"/> class. /// </summary> /// <param name="type">Button Type.</param> /// <param name="player">Player input accepted.</param> /// <param name="name">Name from Unitys settings.</param> public InputExButtonMap(ButtonTypes type, ControllerPlayers player, string name) { this.Type = type; this.Player = player; this.Name = name; }
private static string findAnalogName(AnalogTypes type, ControllerPlayers player) { foreach (var map in AnalogMappings) { if (map.Type == type && map.Player == player) { return map.Name; } } Debug.LogError(string.Format("Failed to find Analog {0} for Player {1}", type, player)); return "Unknown"; }
/// <summary> /// Gets the Analog Axis value with no tolerance /// </summary> /// <returns>The axis.</returns> /// <param name="type">Analog Type.</param> /// <param name="player">Player input accepted.</param> public static float GetAxisRaw(AnalogTypes type, ControllerPlayers player) { return Input.GetAxisRaw(findAnalogName(type, player)); }
/// <summary> /// Gets if the button was let up /// </summary> /// <returns>Returns if valid or not</returns> /// <param name="type">Button Type.</param> /// <param name="player">Player input accepted.</param> public static bool GetButtonUp(ButtonTypes type, ControllerPlayers player) { InputExButtonMap mapping; string name = findButtonName(type, player, out mapping); if (mapping != null && mapping.analogUp) return true; return Input.GetButtonUp(name); }
private static string findButtonName(ButtonTypes type, ControllerPlayers player, out InputExButtonMap mapping) { foreach (var map in ButtonMappings) { if (map.Type == type && map.Player == player) { mapping = map; return map.Name; } } Debug.LogError(string.Format("Failed to find Button {0} for Player {1}", type, player)); mapping = null; return "Unknown"; }