private void CheckInputs_Keyboard(KS_Scriptable_Input_object input) { if (Enum.IsDefined(typeof(KeyCode), parser.Get(input.ID))) { input.curKey = (KeyCode)Enum.Parse(typeof(KeyCode), parser.Get(input.ID)); } else { parser.Set("Keyboard", input.ID, input.DefaultKey.ToString()); input.curKey = input.DefaultKey; } }
/// <summary> /// Is input currently being pressed /// </summary> /// <param name="ID">Input ID as set in Input Manager editor window</param> /// <returns></returns> public static bool GetInput(string ID) { KS_Scriptable_Input_object key = FindInput(ID); Debug.Log(ID); if (key != null) { Debug.Log(ID + " Found: " + key.curKey.ToString()); return(UnityEngine.Input.GetKey(key.curKey)); } return(false); }
private void CheckInputs_Mouse(KS_Scriptable_Input_object input) { int i; if (int.TryParse(parser.Get(input.ID), out i)) { input.curMouseButton = i; } else { parser.Set("Mouse", input.ID, input.MouseButton.ToString()); input.curMouseButton = input.MouseButton; } }
/// <summary> /// Is input currently being pressed up /// </summary> /// <param name="ID">Input ID as set in Input Manager editor window</param> /// <returns>True the moment the input is released else False</returns> public static bool GetInputUp(string ID) { KS_Scriptable_Input_object key = FindInput(ID); if (key != null) { if (key.UseDS4) { if (UnityEngine.Input.GetKeyUp(DS4ButtonToKey(key.DefaultDS4))) { return(true); } } return(UnityEngine.Input.GetKeyUp(key.curKey)); } return(false); }
/// <summary> /// Get the current readings for an Axis /// </summary> /// <param name="ID">Axis ID as set in Input Manager editor window</param> /// <returns>Float axis reading from -1 to 1, if above 1 its mouse reading</returns> public static float GetAxis(string ID) { KS_Scriptable_Input_object key = FindInput(ID); if (key != null) { float DS4 = 0, xbox = 0, mouse = 0, keyboard = 0; float axisPos = 0, axisNeg = 0; if (key.UseDS4) { DS4 = GetDS4Axis(key.DS4Axis); if (DS4 > 0 && DS4 < key.deadZone) { DS4 = 0; } if (DS4 < 0 && DS4 > -key.deadZone) { DS4 = 0; } if (DS4 > 0) { axisPos = DS4; } else { axisNeg = DS4; } } if (key.UseXbox) { xbox = 0f; if (xbox > 0 && DS4 < key.deadZone) { xbox = 0; } if (xbox < 0 && DS4 > -key.deadZone) { xbox = 0; } } if (key.mouseX) { mouse = UnityEngine.Input.GetAxis("Mouse X"); if (mouse < axisNeg) { axisNeg = mouse; } else if (mouse > axisPos) { axisPos = mouse; } } if (key.mouseY) { mouse = UnityEngine.Input.GetAxis("Mouse Y"); if (mouse < axisNeg) { axisNeg = mouse; } else if (mouse > axisPos) { axisPos = mouse; } } if (key.positive != KeyCode.None) { if (UnityEngine.Input.GetKey(key.positive)) { keyboard = 1f; } if (UnityEngine.Input.GetKey(key.negitive)) { if (keyboard > 0) { keyboard = 0f; } else { keyboard = -1f; } } if (keyboard < axisNeg) { axisNeg = keyboard; } else if (keyboard > axisPos) { axisPos = keyboard; } } if (axisNeg != 0) { return(axisNeg += axisPos); } else { return(axisPos); } } return(0f); }