r2mods/ilspy_dump/ror2_csproj/RoR2.UI/DefaultSettings.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using Rewired;
using UnityEngine;
namespace RoR2.UI;
public class DefaultSettings : MonoBehaviour
{
public void DefaultControllerMapping(Player player)
{
if (player == null)
{
return;
}
Controller lastActiveController = player.controllers.GetLastActiveController(ControllerType.Joystick);
if (lastActiveController == null)
{
return;
}
JoystickMap defaultJoystickMap = DefaultControllerMaps.GetDefaultJoystickMap(lastActiveController.hardwareTypeGuid);
if (defaultJoystickMap == null)
{
return;
}
LocalUser localUser = LocalUserManager.FindLocalUser(player);
if (localUser != null)
{
localUser.userProfile.joystickMap = defaultJoystickMap;
localUser.userProfile.UpdateJoystickMap(lastActiveController.hardwareTypeGuid, defaultJoystickMap);
localUser.ApplyUserProfileBindingsToRewiredPlayer();
localUser.userProfile.RequestEventualSave();
MPEventSystem.RefreshAllControllerGlyphs();
if (InputBindingDisplayController.onBindingsChanged != null)
{
InputBindingDisplayController.onBindingsChanged();
}
}
}
public void RestoreDefaultControllerSettings(Player player)
{
DefaultControllerMapping(player);
}
}