static void SetButtons() { if (!modEnabled.Value || ZInput.instance == null) { return; } ZInput zInput = ZInput.instance; Dictionary <string, ZInput.ButtonDef> m_buttons = Traverse.Create(zInput).Field("m_buttons").GetValue <Dictionary <string, ZInput.ButtonDef> >(); m_buttons.Clear(); using (var enumerator = context.Config.GetEnumerator()) { while (enumerator.MoveNext()) { if (enumerator.Current.Key.Section == "Config") { continue; } ButtonInfo info = new ButtonInfo(enumerator.Current.Key.Key, (ConfigEntry <string>)enumerator.Current.Value); if (Enum.TryParse <KeyCode>(info.key, out KeyCode keyCode)) { zInput.AddButton(info.button, keyCode, info.repeatDelay, info.repeatInterval); } else { zInput.AddButton(info.button, info.key, info.inverted, info.repeatDelay, info.repeatInterval); } } } zInput.Save(); Dbgl("Finished setting buttons"); }
internal void Load(ZInput zinput) { Debug.Log("---- Registering custom inputs ----"); if (zinput == null) { Debug.LogError("\t-> ZInput does not exist yet, delaying..."); return; } foreach (var pair in Buttons) { var btn = pair.Value; if (btn.Axis != null && btn.Axis.Length > 0) { zinput.AddButton(btn.Name, btn.Axis, btn.Inverted, btn.RepeatDelay, btn.RepeatInterval); } else { zinput.AddButton(btn.Name, btn.Key, btn.RepeatDelay, btn.RepeatInterval); } Debug.Log("Registered input: " + pair.Key); } }
static public void Postfix(ZInput __instance) { foreach (var button in Buttons) { __instance.AddButton(button.name, button.code); } }
private void RegisterCustomInputs(On.ZInput.orig_Reset orig, ZInput self) { orig(self); Logger.LogInfo("---- Registering custom inputs ----"); foreach (var pair in Buttons) { var btn = pair.Value; if (btn.Axis != null && btn.Axis.Length > 0) { self.AddButton(btn.Name, btn.Axis, btn.Inverted, btn.RepeatDelay, btn.RepeatInterval); } else { self.AddButton(btn.Name, btn.Key, btn.RepeatDelay, btn.RepeatInterval); } Logger.LogInfo($"Registered input {pair.Key}"); } }
public static void Postfix(ref ZInput __instance) { __instance.AddButton("TogglePins", KeyCode.T); m_keyInit = true; }