| 79 | } |
| 80 | |
| 81 | bool InputButton::isPressed() const |
| 82 | { |
| 83 | if (m_type == InputType::Mouse) |
| 84 | return sf::Mouse::isButtonPressed(std::get<sf::Mouse::Button>(m_button)); |
| 85 | if (m_type == InputType::GamepadButton) |
| 86 | return sf::Joystick::isButtonPressed( |
| 87 | m_gamepadIndex, std::get<unsigned int>(m_button)); |
| 88 | if (m_type == InputType::GamepadAxis) |
| 89 | { |
| 90 | const float axisValue = sf::Joystick::getAxisPosition( |
| 91 | m_gamepadIndex, std::get<sf::Joystick::Axis>(m_button)); |
| 92 | return (m_detectAxis.first == AxisThresholdDirection::Less) |
| 93 | ? axisValue < m_detectAxis.second |
| 94 | : axisValue > m_detectAxis.second; |
| 95 | } |
| 96 | |
| 97 | return sf::Keyboard::isKeyPressed(std::get<sf::Keyboard::Key>(m_button)); |
| 98 | } |
| 99 | |
| 100 | float InputButton::getAxisPosition() |
| 101 | { |
no outgoing calls
no test coverage detected