static KeyboardState Postfix(KeyboardState k, KeyboardState __result) { if (MultipleKeyboardManager.HasAttachedKeyboard()) { return(MultipleKeyboardManager.GetAttachedKeyboardState() ?? new KeyboardState()); } return(__result); }
public override void Entry(IModHelper helper) { //Setup Montior new SplitScreen.Monitor(Monitor); //Get player index if it is set in launch options, e.g. StardewModdingAPI.exe --log-path "third.txt" --player-index 3 this.playerIndexController = new PlayerIndexController(Environment.GetCommandLineArgs()); //Stardew Valley uses this as the target controller for rumble(and nothing else it seems) Game1.playerOneIndex = PlayerIndexController._PlayerIndex.GetValueOrDefault(); //Removes FPS throttle when window inactive Game1.game1.InactiveSleepTime = new TimeSpan(0); var harmony = HarmonyInstance.Create("me.ilyaki.splitscreen"); harmony.PatchAll(Assembly.GetExecutingAssembly()); Helper.Events.Input.ButtonPressed += InputEvents_ButtonPressed; Helper.Events.GameLoop.UpdateTicked += delegate { Game1.game1.SetPrivateFieldValue("isActive", true); }; //only do when in-game? //Keyboards/Mice Managers kbManager = new Keyboards.MultipleKeyboardManager(harmony); Helper.Events.GameLoop.UpdateTicked += kbManager.OnUpdate; Helper.Events.GameLoop.ReturnedToTitle += kbManager.OnAfterReturnToTitle; miceManager = new Mice.MultipleMiceManager(); Helper.Events.Specialized.UnvalidatedUpdateTicked += miceManager.OnUpdateTick; Helper.Events.GameLoop.ReturnedToTitle += miceManager.OnAfterReturnToTitle; //Set the affinity for all SMAPI processes. Adjustments are handled by AffinityButtonMenu var processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); int processorCount = Environment.ProcessorCount; for (int i = 0; i < processes.Count(); i++) { int designatedCPU = i % processorCount; designatedCPU = processorCount - designatedCPU - 1; //Start backwards (Use the last core for the first instance) try { processes[i].ProcessorAffinity = (IntPtr)(1 << designatedCPU); } catch (Exception e) { Monitor.Log($"Could not set affinity for {i}: {e.ToString()}", LogLevel.Debug); } } //Load the config this.config = Helper.ReadConfig <ModConfig>(); if (!Enum.TryParse(this.config.MenuKey, out menuKey)) { menuKey = Keys.N; } }
//Seems unecessary? static bool Prefix() { return(!MultipleKeyboardManager.HasAttachedKeyboard()); }