-
-
Save vaindil/30454640cd0c91b5f8697a7e01d513d4 to your computer and use it in GitHub Desktop.
Quick and dirty Harmony mod to completely disable the gamepad in Stardew Valley. Only tested on Windows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Harmony; | |
using Microsoft.Xna.Framework; | |
using Microsoft.Xna.Framework.Input; | |
using StardewModdingAPI; | |
using StardewModdingAPI.Events; | |
using System; | |
using System.Reflection; | |
namespace SdvGamePad | |
{ | |
public class ModEntry : Mod | |
{ | |
public override void Entry(IModHelper helper) | |
{ | |
var harmony = HarmonyInstance.Create("com.vaindil.DisableSdvGamepad"); | |
harmony.PatchAll(Assembly.GetExecutingAssembly()); | |
InputEvents.ButtonPressed += (s, e) => | |
{ | |
if (e.Button == SButton.NumPad0) | |
{ | |
var state = GamePad.GetState(PlayerIndex.One); | |
Console.WriteLine("Gamepad connected? " + state.IsConnected); | |
} | |
}; | |
} | |
} | |
[HarmonyPatch(typeof(GamePadState))] | |
[HarmonyPatch("IsConnected", PropertyMethod.Getter)] | |
internal static class GamePadKiller | |
{ | |
private static void Postfix(ref bool __result) | |
{ | |
__result = false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment