public float GetAxis(AxisMethodName g_input, int g_joystickNumber, JoystickAxis g_axis) { //check if it use simulator if (useSimulator) { if (mySimulatorDictionary.ContainsKey(g_joystickNumber)) { float t_value = mySimulatorDictionary [g_joystickNumber].GetAxis(g_axis); if (t_value != 0) { return(t_value); } } } //get the input function AxisMethod t_InputFunction; if (g_input == AxisMethodName.Normal) { t_InputFunction = Input.GetAxis; } else { t_InputFunction = Input.GetAxisRaw; } //0 -> all; 1-8 -> joystick1-8 g_joystickNumber = Mathf.Clamp(g_joystickNumber, 0, NUMBER_MAX_JOYSTICK); if (g_joystickNumber != 0) { JellyJoystickInputLayout t_layout = GetInputLayout(g_joystickNumber); int t_axisNumber = t_layout.GetAxisNumber(g_axis); if (t_axisNumber == 0) { return(0); } int t_axisMultiplier = t_layout.GetAxisMultiplier(g_axis); return(t_InputFunction("Joystick" + g_joystickNumber + "Axis" + t_axisNumber) * t_axisMultiplier); } else { for (int i = 1; i <= NUMBER_MAX_JOYSTICK; i++) { float t_value = GetAxis(g_input, i, g_axis); if (t_value != 0) { return(t_value); } } } return(0); }
public bool GetButton(ButtonMethodName g_input, int g_joystickNumber, JoystickButton g_button) { //check if it use simulator if (useSimulator) { if (mySimulatorDictionary.ContainsKey(g_joystickNumber) && mySimulatorDictionary [g_joystickNumber].GetButton(g_input, g_button)) { return(true); } } //get the input function ButtonMethod t_InputFunction; if (g_input == ButtonMethodName.Up) { t_InputFunction = Input.GetKeyUp; } else if (g_input == ButtonMethodName.Hold) { t_InputFunction = Input.GetKey; } else { t_InputFunction = Input.GetKeyDown; } //0 -> all; 1-8 -> joystick1-8 g_joystickNumber = Mathf.Clamp(g_joystickNumber, 0, NUMBER_MAX_JOYSTICK); if (g_joystickNumber != 0) { JellyJoystickInputLayout t_layout = GetInputLayout(g_joystickNumber); int t_buttonNumber = t_layout.GetButtonNumber(g_button); if (t_buttonNumber == -1) { return(false); } return(t_InputFunction(GetKeyCode(t_buttonNumber, g_joystickNumber))); } else { for (int i = 1; i <= NUMBER_MAX_JOYSTICK; i++) { if (GetButton(g_input, i, g_button)) { return(true); } } } return(false); }