Skip to content

Instantly share code, notes, and snippets.

@vaindil
Created June 26, 2018 02:25
Show Gist options
  • Save vaindil/30454640cd0c91b5f8697a7e01d513d4 to your computer and use it in GitHub Desktop.
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.
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