Skip to content

Commit 320f8d1

Browse files
committed
Fix SetButton Method
1 parent 0b1cef8 commit 320f8d1

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

EmoteWheel/EmoteWheel.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ void OnDestroy()
122122
harmony?.UnpatchAll();
123123
}
124124

125+
private static void SetButtonKey(string name, KeyCode keyCode)
126+
{
127+
var buttons = GetButtonsFromZInput();
128+
buttons[name].m_key = keyCode;
129+
}
130+
131+
private static Dictionary<string, ZInput.ButtonDef> GetButtonsFromZInput()
132+
{
133+
return (Dictionary<string, ZInput.ButtonDef>)typeof(ZInput).GetField("m_buttons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ZInput.instance);
134+
}
135+
125136
public static void ReplaceGamepadButton()
126137
{
127138
if (ZInput.instance != null)
@@ -141,7 +152,8 @@ public static void ReplaceGamepadButton()
141152
replacedButtons.Add(entry.Key);
142153
replacedKey = keyCode;
143154

144-
ZInput.instance.Setbutton(entry.Key, KeyCode.None);
155+
156+
SetButtonKey(entry.Key, KeyCode.None);
145157
}
146158
}
147159
}
@@ -155,8 +167,7 @@ public static void RestoreGamepadButton()
155167
{
156168
foreach (var button in replacedButtons)
157169
{
158-
ZInput.instance.Setbutton(button, replacedKey);
159-
170+
SetButtonKey(button, replacedKey);
160171
}
161172
replacedButtons.Clear();
162173
replacedKey = KeyCode.None;

0 commit comments

Comments
 (0)