MegabonkInput

版本 v1.0.0·更新於 2025-10-05

A library to enable easy and reliable hotkeys on keyboard and gamepad for Windows.

模組介紹 作者原文

What?

This is a library mod that hooks all window messages sent to the game window, allowing reliable input processing and the potential for input blocking and acting on messages such as losing and gaining focus. It doesn't add any functionality to the game by itself, but rather exposes a single constructor on the class "Keybind" and properties to control the keybinds behaviour during runtime.

Why?

I arbitrarily decided I wanted keyboard hotkeys. I spent 3 minutes learning it was possible, 30 minutes failing to find a reference to normal input systems in Megabonk, 3 hours researching Rewired and how I might hook it at runtime, and 30 hours writing this alternative, in that order.

On one hand I expect theres an easier way like importing a unity dll or hooking a Rewired method I missed, but on the other this one is flexible and really easy to use. It also brings me one step closer to a Dear ImGui Injector.

How?

You just need to

  • Include MegabonkInput.dll in your project
  • Integrate the MegabonkInput.Keybind type into your code following the example below
  • Decorate your BasePlugin with [BepInDependency("MegabonkInput")]
  • In your manifest.josn add a dependancy to this mod

Creating a Keybind is as easy as

[BepInDependency("MegabonkInput")]

[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]

public class Plugin: BasePlugin

{

internal static new ManualLogSource Log;

private Keybind myBind;

public override void Load()

{

// Plugin startup logic

Log = base.Log;

Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded!");

// Just instantiating a Keybind sets it up to be active immediatly, no additional method calls needed

// There are three layers of input, by passing "InputLayer.Game | InputLayer.GameUI" this binding will activate when the player has control of a character and in in-game menus, but not in external tools like configurators or trainers

myBind = new Keybind(VirtualKey.VK_DELETE, PressType.WM_KEYDOWN, ExampleAction, InputLayer.Game | InputLayer.GameUI);

}

// This method will be activated each time the Keybinds key is pressed

private void ExampleAction() {

Log.LogInfo($"Keybind was pressed -> {myBind.Key}");

// This keybind is self editing!

if (myBind.Key == VirtualKey.VK_DELETE) {

myBind.Key = VirtualKey.VK_END;

} else {

myBind.Key = VirtualKey.VK_DELETE;

}

}

}

Who?

Not only is it astoundingly easy to use, but it was also really easy to write. Most of the hard bits came from

Shoutouts to all of the modders who have touched that source code.

It should be easy to expand the functionality to support mouse events and window focusing just as examples, they're all just messages already passing through the mod's handler, so if you have a particular need let me know.

-Rivinwin

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack_IL2CPP

檔案與校驗

檔案名稱
MegabonkInput-1.0.0.zip
檔案大小
85.4 KiB