using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TopsyTurvy")]
[assembly: AssemblyDescription("A simple mod that allows configuration options to invert the X axis and the Y axis mouse controls independently, for accessibility and alternate input methods.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("FluxTeam")]
[assembly: AssemblyProduct("TopsyTurvy")]
[assembly: AssemblyCopyright("Copyright © FluxTeam 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6C3B2913-AED6-4AA0-BDC4-753FE5184EBA")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TopsyTurvy
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "FluxTeam.TopsyTurvy";
public const string PLUGIN_NAME = "TopsyTurvy";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("FluxTeam.TopsyTurvy", "TopsyTurvy", "1.0.0")]
public class TopsyTurvyPlugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static ConfigEntry<bool> InvertXAxis;
public static ConfigEntry<bool> InvertYAxis;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
InvertXAxis = ((BaseUnityPlugin)this).Config.Bind<bool>("Mouse Controls", "InvertXAxis", false, "Invert the horizontal (X) axis mouse movement");
InvertYAxis = ((BaseUnityPlugin)this).Config.Bind<bool>("Mouse Controls", "InvertYAxis", false, "Invert the vertical (Y) axis mouse movement");
Logger.LogInfo((object)"Plugin FluxTeam.TopsyTurvy is loaded!");
Logger.LogInfo((object)$"X Axis Inversion: {InvertXAxis.Value}");
Logger.LogInfo((object)$"Y Axis Inversion: {InvertYAxis.Value}");
Harmony.CreateAndPatchAll(typeof(MouseInputPatches), (string)null);
}
}
[HarmonyPatch]
public class MouseInputPatches
{
[HarmonyPatch(typeof(Input), "GetAxis")]
[HarmonyPostfix]
public static void Input_GetAxis_Postfix(string axisName, ref float __result)
{
try
{
if (axisName == "Mouse X" && TopsyTurvyPlugin.InvertXAxis.Value)
{
__result = 0f - __result;
}
else if (axisName == "Mouse Y" && TopsyTurvyPlugin.InvertYAxis.Value)
{
__result = 0f - __result;
}
}
catch (Exception ex)
{
TopsyTurvyPlugin.Logger.LogError((object)("Error in Input_GetAxis_Postfix: " + ex.Message));
}
}
[HarmonyPatch(typeof(Input), "GetAxisRaw")]
[HarmonyPostfix]
public static void Input_GetAxisRaw_Postfix(string axisName, ref float __result)
{
try
{
if (axisName == "Mouse X" && TopsyTurvyPlugin.InvertXAxis.Value)
{
__result = 0f - __result;
}
else if (axisName == "Mouse Y" && TopsyTurvyPlugin.InvertYAxis.Value)
{
__result = 0f - __result;
}
}
catch (Exception ex)
{
TopsyTurvyPlugin.Logger.LogError((object)("Error in Input_GetAxisRaw_Postfix: " + ex.Message));
}
}
}
}