/** * FUNCTION NAME: GetDictioanryValue * DESCRIPTION : Get the current press value stored in the input dictionary. * INPUTS : input - Button to check value for. * mode - Mode of input to detect. * OUTPUTS : bool - Input status to report back. **/ public bool GetDictioanryValue(LPK_DispatchOnGamepadInput.LPK_ControllerButtons input, LPK_ReturnInput mode) { //Single button check. if (input != LPK_DispatchOnGamepadInput.LPK_ControllerButtons.ANY) { if (m_dInputList[input] == mode) { return(true); } else { return(false); } } //Any button check. else { for (int i = 0; i < m_dInputList.Count; i++) { if (m_dInputList[(LPK_DispatchOnGamepadInput.LPK_ControllerButtons)i] == mode) { return(true); } } } return(false); }
/** * FUNCTION NAME: UpdateDictionaryTrigger * DESCRIPTION : Update the input state of triggers. * INPUTS : prevState - Previous state of the trigger on frame - 1. * currentState - Current state of the trigger on frame. * matchButton - Trigger input to update in the dictionary. * OUTPUTS : None **/ void UpdateDictionaryTrigger(float prevState, float currentState, LPK_DispatchOnGamepadInput.LPK_ControllerButtons matchButton) { if (prevState >= m_flDeadZone && currentState >= m_flDeadZone) { m_dInputList[matchButton] = LPK_ReturnInput.HELD; } else if (prevState >= m_flDeadZone && currentState < m_flDeadZone) { m_dInputList[matchButton] = LPK_ReturnInput.RELEASED; } else if (prevState < m_flDeadZone && currentState >= m_flDeadZone) { m_dInputList[matchButton] = LPK_ReturnInput.PRESSED; } else { m_dInputList[matchButton] = LPK_ReturnInput.NONE; } }
/** * FUNCTION NAME: UpdateDictionaryButton * DESCRIPTION : Update the input state of buttons. * INPUTS : prevState - Previous state of the button on frame - 1. * currentState - Current state of the button on frame. * matchButton - Button input to update in the dictionary. * OUTPUTS : None **/ void UpdateDictionaryButton(ButtonState prevState, ButtonState currentState, LPK_DispatchOnGamepadInput.LPK_ControllerButtons matchButton) { if (prevState == ButtonState.Pressed && currentState == ButtonState.Pressed) { m_dInputList[matchButton] = LPK_ReturnInput.HELD; } else if (prevState == ButtonState.Pressed && currentState == ButtonState.Released) { m_dInputList[matchButton] = LPK_ReturnInput.RELEASED; } else if (prevState == ButtonState.Released && currentState == ButtonState.Pressed) { m_dInputList[matchButton] = LPK_ReturnInput.PRESSED; } else { m_dInputList[matchButton] = LPK_ReturnInput.NONE; } }
/** * FUNCTION NAME: CreateDictionary * DESCRIPTION : Creates all entries into the dictionary of inputs. * INPUTS : None * OUTPUTS : None **/ void CreateDictionary(LPK_DispatchOnGamepadInput.LPK_ControllerButtons input) { m_dInputList.Add(input, LPK_ReturnInput.NONE); }
/** * FUNCTION NAME: UpdateDictionaryTrigger * DESCRIPTION : Update the input state of joysticks in left and down. * INPUTS : prevState - Previous state of the joystick on frame - 1. * currentState - Current state of the joystick on frame. * deadZone - Deadzone of the joystick to ignore input. * matchButton - Joystick input to update in the dictionary. * OUTPUTS : None **/ void UpdateDictionaryJoystickReverse(float prevState, float currentState, float deadZone, LPK_DispatchOnGamepadInput.LPK_ControllerButtons matchButton) { if (prevState <= deadZone && currentState <= deadZone) { m_dInputList[matchButton] = LPK_ReturnInput.HELD; } else if (prevState <= deadZone && currentState > deadZone) { m_dInputList[matchButton] = LPK_ReturnInput.RELEASED; } else if (prevState > deadZone && currentState <= deadZone) { m_dInputList[matchButton] = LPK_ReturnInput.PRESSED; } else { m_dInputList[matchButton] = LPK_ReturnInput.NONE; } }