// ------------------ public bool IsDuplicateOf(GamepadProfile profile) { if (!this.joystickIdentifier.Equals(profile.joystickIdentifier, System.StringComparison.OrdinalIgnoreCase)) { return(false); } for (int i = 0; i < GamepadManager.GamepadKeyCount; ++i) { if (!this.GetKeySource(i).IsDuplicateOf(profile.GetKeySource(i))) { return(false); } } for (int i = 0; i < GamepadManager.GamepadStickCount; ++i) { if (!this.GetJoystickSource(i).IsDuplicateOf(profile.GetJoystickSource(i))) { return(false); } } return(true); }
// --------------------- virtual protected GamepadProfile GetInternalGenericProfile() { if (this.genericProfile == null) { this.genericProfile = new GamepadProfile.GenericProfile(); } return(this.genericProfile); }
// -------------------- public int FindDuplicate(GamepadProfile profile) { for (int i = 0; i < this.profileList.Count; ++i) { if (this.profileList[i].IsDuplicateOf(profile)) { return(i); } } return(-1); }
// ------------------- public GamepadProfile GetProfile(string deviceName) { for (int i = 0; i < this.profileList.Count; ++i) { GamepadProfile profile = this.profileList[i]; if (profile.IsCompatible(deviceName)) { return(profile); } } return(null); }
// ------------------- public void GetCompatibleProfiles(string deviceName, List <GamepadProfile> targetList) { for (int i = 0; i < this.profileList.Count; ++i) { GamepadProfile profile = this.profileList[i]; if (profile.IsCompatible(deviceName)) { if (!targetList.Contains(profile)) { targetList.Add(profile); } } } }
// ------------------- public GamepadProfile AddProfile(GamepadProfile profile) { if (profile == null) { return(null); } int duplicateId = this.FindDuplicate(profile); if (duplicateId >= 0) { GamepadProfile originalProfile = this.profileList[duplicateId]; this.profileList.RemoveAt(duplicateId); this.profileList.Insert(0, originalProfile); originalProfile.AddSupportedVersion(profile.unityVerTo); return(originalProfile); } this.profileList.Insert(0, profile); return(profile); }